Space Invaders with Vanilla JavaScript

Screenshot 2015-04-20 21.46.30

Play it here!

For hack night a couple of weeks ago, I followed a 30-minute live coding demo by Mary Rose Cook where she made a simple Space Invaders browser game using only vanilla Javascript and HTML - no libraries, no frameworks.

I added some minor improvements of my own, mainly:

  • Different colors for the bullets, player, and invader

  • "Start Game" / "Play Again" buttons, with "Game Over" / "Player Wins" message

  • Bullets can't destroy each other

  • Limit player's firing rate (it was basically a machine gun as implemented)

  • Variation in invaders' color and design

  • "Classic" Space Invaders color scheme and old school font

...all while sticking to the philosophy of plain JavaScript of course. I learned some stuff about basic JavaScript/DOM interaction (that you miss when you're always using jQuery) and HTML canvas.

Check it out.

Source code can be found at my Github repo.