Spacius! A Space Adventure
I must have been feeling nostalgic, missing my wasted hours playing old Nintendo games as a kid, because last weekend I put together Spacius! A Space Adventure. My goal was to make a fun, simple game using only JavaScript that would work in any browser. That's right folks, this game was made using just div elements! Really, there's nothing hardcore in here that would require canvas, so I guess that shouldn't blow any minds. But this game has been tested and works in IE6, IE7, FireFox 2/3, Opera 9.5 and Safari 3.
My one cop-out was falling back on flash for the audio, but until all browsers support HTML5 (or some mad genius makes a JavaScript-only audio player), this is the best I could do. Spacius! uses Scott Schiller's fantastic Sound Manager 2 to enable sound. There's a little latency, but it otherwise works like a charm.
One really cool thing about the way Spacius! works is that it takes the shape of its containing element. So it was really trivial to make an 800x600 pixel version.
Here's how to play: Press the space bar to begin the game. Use the arrow keys to move the ship. Once playing, use the space bar to shoot balls of excitement. The S key toggles sound on/off.
There are six waves in Spacius!. The last one begins at 10,000 points, and it's really hard so only total badasses will be able to get super high scores (yes, that's a challenge).
Here are the UFO scores:
Bomber: 15 points
Bogey: 20 points
Meteor: 50 points
"Death Star": 25 points
So what're you waiting for?? PLAY NOW!


Awesome job Matt.. :D
Nice job. I especially like the starfield background. On C64 I always used to fake that with multiplexed sprites which was a bit of job to make work cross NTSC/PAL… OK I do shut up now :)
[...] Matt also shows you what the score is and give some more game info on his blog. [...]
Nice work! Pretty speedy and smoothly-animated, too. Hope the sound bit was easy to add. ;)
Funtastic. With a pair of high top tennies and pegged jeans, I was back in junior high.
Cool but as Matt says, nothing hardcore here : there was similar shoot’em up on the now defunct T_T http://www.javascript-games.org circa 2001.
CSS sprites are perfect for that kind of job.
[...] Matt also shows you what the score is and give some more game info on his blog. [...]
good job mate
Great work! I’m especially surprised by the displayed performance. On my not-particularly-fast processor (1.6GHz Celeron) it’s perfectly smooth, unlike other similar games I’ve played in the past. Do you have any notable tricks to share, or was it just plain old careful programming?
Wow, and I thought at night you just surfed…um, yeah. Nice work dude!
this is seriously awesome!
Wow, i’m impressed. It’s not very often you see a fully fledged game written entirely in JavaScript.
I’m also glad you’ve not used the Canvas. It may be a powerful freeform drawing tool, but it sure gets slow when you get past a certain number of objects redrawn each frame. Not to mention the CPU usage - ack!
Would be interesting to see how far one can push the limits of DIV manipulation.
Also check out my port of a SCUMM interpreter to JavaScript (rather, haXe compiled to JavaScript). Sadly not enough is implemented to make it playable, but i think if you consider it loads + renders room graphics straight from the original resources to the canvas, and the same code compiles to Flash too, it is quite cool. Makes me wonder what else is on the horizon for JavaScript games.
http://www.cuppadev.co.uk/oldbrew/scumm-in-javascript/
Keep up the good work! :)
It’s me again. On Linux x86_64 I’ve had both Opera 9.51 and Firefox 3 running very slowly and then locking up after a few seconds. I can play just fine on Konqueror (3.59) and Midori (WebKit-based), though.
great job. i enjoy the smoothness, that is tough to achieve in js. i am doing something similar here: http://code.google.com/p/js-blaster/ , it is not finnished , but you can play the basics . if anyone interested to join , you are most welcomed. AI and network skills are mostly needed.
Hello, Matt!
Spacius is very cool - I love to see new things developed in JavaScript.
For some reason in FireFox 2, when I push the right arrow key the spaceship disappears. When I don’t more or move using any other key, it appears just fine.
Thanks for your effort - I’ve enjoyed playing!
[...] Nueva hazaña en Javascript: Spaciusscriptnode.com/article/spacius-a-space-adventure/ por galchwyn hace pocos segundos [...]
Hello
Several browsers have built in sound playing capabilities including IE.
I wrote up some code a while back that would check to see what is supported in the current browser and fall back to using flash for sound only as a last resort.
You may be interested in a blog post I did about it:
http://www.ajaxonomy.com/2008/ajax/cross-browser-sound-flash-only-as-a-last-resort
[...] Matt also shows you what the score is and give some more game info on his blog. [...]
[...] great example of taking javascript to its limits. It’s a game called Spacius! A Space Adventure (a port of the original game from ages ago), which has been made using only Javascript, except for [...]
Any chance you’d share the un-minified source?
Cool
Now make Defender!!!
or Scramble!!!
[...] блоге (http://scriptnode.com/article/spacius-a-space-adventure/) Matt Hackett написал о своей игрушке Spacius!, которая придется [...]