More Code With My Son: A New Game – Blob Attack

Before you read my ramblings, here is Ahan’s blog post about the game.

After our last attempt implementing the card game 7-8, this time around we set about making a game totally invented by Ahan called Blob Attack. It’s not yet complete, but playable now (visit his blog post for a link – seriously, no clickable link on this page because he wants to see his blog stats go up), and code has gotten a lot more fun* for Ahan as he spends half his time playing his own game and adjusting the settings to get just the right level of difficulty in higher levels.

The game is built completely in JavaScript and only uses jQuery and native html elements. This time we used a lot more language features.

  • ES6 classes – we switched from the old function as a class
  • Anonymous functions
  • Deeper dive into events
  • Different strategies for class properties
  • Working around the difficulties with class methods being fired from events
  • We also learned about inheritance as every class in the game inherited from the same base class, polymorphism is next.
  • We also worked a little bit on performance. The game was “glitching” in Ahan’s words and we fixed that by deleting unused DOM elements of lasers that had long departed the screen.

We also had some fun** trying to figure out the math for rectangle collisions.

While in our previous game, we started without classes and eventually ended up converting to object oriented programming as the code became more and more complicated, this time we started out with classes to begin with.



Here is a screen shot of the game showing some blobs and lasers:

After this, I’m hoping to look into some HTML 5 game engines, recommendations welcome.

1 thought on “More Code With My Son: A New Game – Blob Attack

Leave a Reply

Your email address will not be published.