Online computer courses, code, programming tutorial and sidebar information for monitoring Canadian S&P/TSX index. Build friendship and networking. Welcome to visit my blogs often!!! I also have two other sites: YouTube Channel and Google site.
Adsense
Popular Posts
- PHPWind-- A PHP forum script applcaition in China
- How to blend adsense inside your post?
- Formatting my post
- Notepad++ - Add C++ compiler
- Install PHPMailer 5.2.4 and use smtp gmail
- Set up a child account and set screen time limit in Windows 8
- Wayback Machine - see archived versions of web pages across time
- phpexcel toggle expand and hide column in EXCEL and summary
- Install PHP ibm_db2 extension in Linux (redHat)
- PHP: add a download as pdf file button in report page
Wednesday, August 8, 2012
Javascript cool application demo
Javascript cool application demo can be found here:
http://js1k.com/2012-love/demos
Below is a simple music Javascript game from this demo: (Click color band to hear music)
Source code:
<script>
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)
</script>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment