
HTML 5 Canvas game  - myth_drannon
http://www.benjoffe.com/code/games/torus/
======
Hexstream
Nicely done!

The first thing I notice is that unlike 90%+ of real-time browser-based games
(flash or javascript), it doesn't stupidly burn 100% CPU for no reason at all.
It takes close to 0%!

~~~
reitzensteinm
You'd probably get the same if you wrote a slow paced, event based game in
Flash. Dirty rects means that even though Flash rendering is called at x fps,
it can be skipped if nothing's changed (at least, as far as I understand it,
my games always change each frame).

Generally if a game has focus it should burn 100% CPU in order to update as
smoothly as possible, but the real problem is games that still update and
consume CPU like that when not in focus.

~~~
Hexstream
But most of those games that burn 100% CPU _still_ burn 100% CPU even if the
game is paused with a static pause screen _and_ the container window is
scrolled past the flash area _and_ the browser window doesn't have focus and
is totally obscured.

So it's obviously not a deliberate tradeoff.

------
Raphael
Wow, that's one of the first JavaScript games that played just like a normal
game, and it didn't feel cheesy like pong. No speed or control issues to
report. Bright, clear, 3D rendering.

Of course, I, like many others, am biased for Tetris.

Oh, and I realized that you got to skip the conditions for turning at the
walls, since it wraps around instead. Still hard, I bet.

~~~
cubicle67
Can I plug my little javascript version of asteroids?
<http://users.tpg.com.au/_dp//dave_asteroids.html>

I've tried to make it not cheesy and nice smooth gameplay

~~~
lacker
Sometimes when it goes to the next level, an asteroid materializes right on
top of me, which seems a bit unsporting.

~~~
unalone
I recall that happening in the original game, too. I could be wrong.

EDIT: "You have died of dysentary." That made me smile.

------
zhyder
Not only is it technically impressive, it's actually fun too! I'm not a gamer
(not even much of a casual gamer) so this may sound like a dumb Q: but are
such variations of Tetris common?

------
ruddzw
It took me a while to realize that my default browser, Safari 3.2.1, doesn't
support HTML 5 Canvas. I'm seeing a bowl and a logo. Graceful degradation, not
so much.

~~~
GHFigs
Safari most certainly does support HTML5 Canvas. The canvas was originally
introduced by Apple in 2004.
([http://weblogs.mozillazine.org/hyatt/archives/2004_07.html#0...](http://weblogs.mozillazine.org/hyatt/archives/2004_07.html#005913))

~~~
ruddzw
You're definitely right. I'm not so familiar with Canvas at all, so I assumed
that since it didn't render, it wasn't supported. My main point was about the
graceful degradation.

------
palish
Seems to be broken in Chrome.

------
whatusername
Do the high scores not work? Or did no-one else finish a game?

~~~
chris11
I got on the highscore list for garbage, so it seems to be working.

~~~
whatusername
hmm.. Can you see anyone else's name on their though? I see my name on
Traditional - but the other 2 spots on that are blank - and all 3 spots on
Time Attack and Garbage are saying "Empty"

~~~
chris11
I guess you are right. I don't see any scores on there at all.

------
lhorie
The opera widget has been around for quite a while.

His other demos seem to run pretty well too (using Flock):
<http://www.benjoffe.com/code/tools/functions3d/>
<http://www.benjoffe.com/code/demos/canvascape/>
<http://www.benjoffe.com/code/toys/spirograph/>

------
cousin_it
This is great, but why Canvas? SVG/VML would be a more natural choice -
JavaScript fits better with a DOM-based API where you don't have to repaint
everything.

------
mis
Cool, works great in FF3 on Ubuntu.

The only thing is that pressing up and down to rotate the tetromino moved the
page up and down as well.

------
DLWormwood
Is it just me, or does the "bin" seem MUCH shallower than an official Tetris
game?

Otherwise, pretty impressive for not using Flash.

------
andhapp
Anyone who does a game in Javascript rocks...so does this one. Amazing...I
didn't even know you could do this...

------
jasonkester
Doesn't work in Chrome, but extra points for being the first Canvas thing here
in a few weeks to support IE!

------
mynameishere
I'm thinking no one did too well. I got the high score of "2". (Unless that's
broken.)

------
jrp
The controls should support holding down L/R instead of tapping only.

~~~
huyslogic
It does support it. Using Firefox. It's perfect.

~~~
axod
Only issue I had is if the window is sized too small to require a scrollbar,
then pressing down/up actually scrolls the page, as well as controlling the
game.

Perhaps need to cancel default action in the key handler...

------
omouse
I'm surprised at how quickly it runs in Firefox.

