Try to win the hearts of your audience by playing along with the music. Hitting a stream when a note reaches the bar at the bottom makes the note disappear. Multiple hits in a row increase your multip…
M=Math;for(T=[L=i=B=''];i<32;)for(k=l=11025,v=i?i-31&&(v+M.random()*3-1)%6|0:1,T[i++]=v+1>>1;k--;)B+=String.fromCharCode(M.sin('28?KTd'.charCodeAt(v)*k/597)*M.min((l-k)/83,k/l)*(i%2&&i%8-3?99:33)+128);A=new Audio('data:audio/wav;base64,UklGRqSIFQBXQVZFZm10IBAAAAABAAEARKwAAESsAAABAAgAZGF0YYCI'+btoa('\0'+B+B+B+B));K=4;onclick=D=function(x,y,w,h){h?a.fillRect(W/2+x*F-w/2,y,w,h):w?a.fillText(w,W/2+x,194+y):(y=(x.pageX-W/2)/M.pow(1.01,x.pageY)+16>>3)>>2?0:K=y};setInterval(function(){N=A.currentTime%32*20|0;N|K&4||A.play(P=0,L=15,X=1);F=4;D(y=0,0,W=c.width=innerWidth,H=c.height=300);for(a.font=4+a.font.slice(a.shadowBlur=1);y<H;y++)for(k=5,F/=.99,f=N+110-y/2,d=f/10|0,a.globalAlpha=y/H;k--;k-4?D(k*2-3,y,1.2*F,1):y-198||D(0,y,260,4)&D(H,103,'♥ '+(L&&P))&D(111,0,'♪ '+(N?X:''))&D(-130,-N*2,'chime hero'))a.fillStyle=s=k-4&&f%10<8|L>=d|d>63|d%4==1|k-T[d%16*2]?'#'+'fa33a0'.substr(k,3):Q='#fff',a.shadowColor=k-K?s:Q;if(n=N/5+1>>1)X=n%4&&L<n-3?0:X,n%4-1&&L<n&K==T[n%16*2]&&(L=n,P+=++X),A.volume=X|!N?1:1e-8;K=4},50)
TT1NYXRoO2ZvcihUPVtMPWk9Qj0nJ107aTwzMjspZm9yKGs9bD0xMTAyNSx2PWk/aS0zMSYmKHYrTS5yYW5kb20oKSozLTEpJTZ8MDoxLFRbaSsrXT12KzE+PjE7ay0tOylCKz1TdHJpbmcuZnJvbUNoYXJDb2RlKE0uc2luKCcyOD9LVGQnLmNoYXJ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zA6WCxuJTQtMSYmTDxuJks9PVRbbiUxNioyXSYmKEw9bixQKz0rK1gpLEEudm9sdW1lPVh8IU4/MToxZS04O0s9NH0sNTAp
///////////////////////////////////////////////////////////////////////////
// _ ♥ _
// ,---¦ '-,-,-----,---, ¦ '-,---,---,---,
// ¦ --¦ , ¦ ¦ , , ¦ -_¦ ¦ , ¦ -_¦ ,-¦ - ¦
// '---'-'-'-'-'-'-'---' '-'-'---'-' '---'
// it's only rock'n'roll (but I like it)
//
//////////////////////////////////////////////////// by @veubeke //////////
//
// This is a simple music game based on a glockenspiel. Notes played run
// down four streams. Click the stream once a note reaches the bar at the
// bottom to win the hearts of your audience. Notes you hit will disappear;
// hitting multiple notes in a row increases your multiplier while missing
// too many notes in a row mutes the music until you hit another one.
// The songs played are automatically generated but quite catchy. ;)
//
// The following code is already pretty minimal. To get it down to 1k you
// just need to remove comments and whitespace and replace variable names.
// No magic needed. For the full documentation visit
//
// http://games.23inch.de/chime/
//
// Features:
//
// + Like a tune? Click to restart it!
// + Don't like a tune? Reload to generate a new one!
// + The music only plays as long as you play.
// + It's all shiny and shit.
// + No 'eval', no 'with', no compression.
//
// Issues:
//
// - There are some artifacts in the sound which is to be expected when
// rounding all values to save space.
// - The game doesn't work in IE9 because apparently you can't have Audio
// and btoa() (base64 encoding) at the same time.
//
// Acknowledgements:
//
// I had the basic idea after seeing @chrissmoak's entry for the first
// js1k which also helped me with figuring out how to construct the audio.
//
// http://js1k.com/2010-first/demo/806
//
// There are a lot of optimizations in here, many of which I saw being
// used in earlier js1k contests. Unfortunately, it's hard to tell who
// came up with something first. However, the last few bytes were shaved
// using some of these tips:
//
// https://github.com/jed/140bytes/wiki/Byte-saving-techniques
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
/// Create Tune (315 bytes)
///////////////////////////////////////////////////////////////////////////
math = Math;
for(tune = [hit = i = track = '']; i<32;)
for(k = l = 11025,
v = i?i-31&&(v+math.random()*3-1)%6|0:1,
tune[i++] = v+1>>1; k--;)
track += String.fromCharCode(
math.sin('28?KTd'.charCodeAt(v)*k/597)
*math.min((l-k)/83, k/l)
*(i%2&&i%8-3?99:33)+128);
player = new Audio('data:audio/wav;base64,UklGRqSIFQBXQVZFZm10IBAAAAA\
BAAEARKwAAESsAAABAAgAZGF0YYCI' + btoa('\0'+track+track+track+track));
///////////////////////////////////////////////////////////////////////////
/// Handle Clicks / Draw Stuff (146 bytes)
///////////////////////////////////////////////////////////////////////////
string = 4;
onclick = draw = function(x,y,w,h) {
h ? a.fillRect(cwidth/2+x*scale-w/2,y,w,h)
: w ? a.fillText(w,cwidth/2+x,194+y)
: (y=(x.pageX-cwidth/2)/math.pow(1.01,x.pageY)+16>>3)>>2
?0: string = y
};
///////////////////////////////////////////////////////////////////////////
/// Game Loop (559 bytes)
///////////////////////////////////////////////////////////////////////////
setInterval(function() {
step = player.currentTime%32*20|0;
step | string&4 || player.play(hearts = 0, hit = 15, mult = 1);
scale = 4;
draw(y=0,0,cwidth=c.width=innerWidth,cheight=c.height=300);
for(a.font = 4+a.font.slice(a.shadowBlur=1); y<cheight; y++)
for(k = 5, scale /= .99,
f = step+110-y/2, d = f/10|0,
a.globalAlpha = y/cheight; k--;
k-4 ? draw(k*2-3,y,1.2*scale,1)
: y-198 || draw(0,y,260,4)&draw(cheight,103,'♥ '+(hit&&hearts))
& draw(111,0,'♪ '+(step?mult:''))
& draw(-130,-step*2,'chime hero'))
a.fillStyle = s = k-4 && f%10<8 | hit>=d | d>63 | d%4==1
| k-tune[d%16*2] ? '#'+'fa33a0'.substr(k,3) : Q='#fff',
a.shadowColor = k-string ? s : Q;
if(n = step/5+1>>1)
mult = n%4 && hit<n-3 ? 0 : mult,
n%4-1 && hit<n & string==tune[n%16*2] && (hit = n, hearts += ++mult),
player.volume = mult | !step ? 1:1e-8;
string = 4
}, 50)