Skip to main content
3 of 20
added 116 characters in body
Bumpy
  • 489
  • 3
  • 6

Not a finished entry yet, but as y'all are too quick for me I'm parking my work-in-progress here now until I find some time to knock it down a bit more more... (Hope that's okay)

Not quite sure about the requirements around the division of the Tweets & the header, but I feel I can squeeze it into four with a little bit more effort. :-)

##Tweet 1 - P0 (11 bytes) chrome a.js

##Tweet 2 - P1 (155 bytes) <-- 15 to remove!! a=0,x=0,R=(b=>{for(o="",i=30;i--;)o+=1<<i&(a|x)?"#":"_",o+=i%5?"":"
";document.body.innerHTML=o}) X=(a=>(j=new Date%3+1,x=12/j<<25,l=1+(j>1),m=4-(j<3)))

##Tweet 3 - P2 (140 bytes) Q=(b=>{for(r=0;r<30;r+=5)m=31<<r,m!=(a&m)||(p=a&1<<r-5,a>>=r+5,a<<=r,a,p);X()}) D=(b=>{x?x<32||x>>5&a?x>1<<25?a=0:(a|=x,x=0):x>>=5:Q();R()})

##Tweet 3 - P3 (142 bytes) <-- 2 to remove!! X(),R(),setInterval(D,700),C=(b=>b&a?x:b) window.onkeyup=(a=>{k=a.keyCode;k-40?k%3&&l>0?(x=C(x<<1),l--):39==k&&l<m&&(x=C(x>>1),l++):D();R()})

I think that's a total of 448 bytes so far... and falling!

(Marginally More) Readable Code

a = 0, // game board x = 0, // real x // Init X at top. x = 4(..#..), 6(..##.) or 12(.##..) 12 & (1/3 , 1/2, 1/1) X = v => (j=new Date % 3 + 1, x = 12 / j << 25, l=1+(j>1), m = 4-(j<3)) // Render R = v => { for (o = '', i = 30; i--;) { // render board o += (1 << i) & (a | x) ? '#' : '_' // &#9637; box o += !(i % 5) ? '<br>' : '' } document.body.innerHTML = o } X() R() // move down D = v => { !x // Send timer to Q (x: 0=Q-phase, -1=Lose!) ? Q() : (x < 32) || ((x >> 5) & a) // If i can't move down (<0 or hit) ? x>1<<25 ? a =0 // Game over man! : (a = a | x, x=0) // Then store final pos'n, set Q round (x=0) & start again. : x >>= 5 // Else just move down R() } // remove completed rows Q = v => { for (r = 0; r < 30; r += 5) { m = 0b11111 << r, (m != (a&m)) || ( p = a & 1 << (r - 5), // store bottom chunk a >>= (r + 5), a <<= r, a & p // slide a down then up to clear, then & p ) } X() // start over } setInterval(D, 700) // Test for L/R C = k => (k & a) ? x : k window.onkeyup = e => { k = e.keyCode k - 40 ? (k % 3) && l > 0 // 39. Right ? (x = C(x << 1), l--) : k == 39 && l < m ? (x = C(x >> 1), l++) : 0 : D() // 1. Down R() }

Or

##Run it minified in JSFiddle: https://jsfiddle.net/CookieJon/tb5e7sns/1/

(Click the output window to give it focus before the keypress events activate, though)

Also, I just noticed a bug with clearing the rows that's crept back into this version - but it's 1:30am, so later... :-)

Bumpy
  • 489
  • 3
  • 6