News for hackers. Stuff that matters.
Re:Snake game in a data: URI by bytex64 on Friday December 09, 2011 @05:53PM (#3336040)
I've merged in your changes and made a few improvements, too. I streamlined the timeout handling so that it uses setTimeout instead of clearing and resetting setInterval. I also used color literals instead of CSS rgb(). I removed the reset to black in I() since recreating the canvas context does that automatically.

Thanks, biot, you are officially awesome!

Re:Snake game in a data: URI by biot on Friday December 09, 2011 @06:59PM (#3336259)
Of course! It's been a while since I've done much javascript and I had forgotten about setTimeout. And your do/while loop in the R() function is much cleaner than my hack. :)

One thing I noticed is that you're setting the timeout value to 350-s.length*5. As the grid is 16x16, the maximum snake length will be 256. Multiplying the length by 5 will soon make the game humanly unplayable somewhere around a length of 60.

Re:Snake game in a data: URI by biot on Sunday December 11, 2011 @06:43AM (#3339883)
Re-reading my comment, it's ambiguous what the "of course" refers to. What I meant: of course I should have used setTimeout rather than the lamer setInterval/clearInterval method.