+44(0)1268 906092 Website specialists

Write a Falling Blocks game in Javascript in 1 hour; so a few years ago I wrote a Falling Blocks game in Java, as a Java applet.

What I did to write a Falling Blocks game

Well I have had it on my long to do list for a long time to rewrite in in Javascript. So last night that is exactly what I did.

And rather than re-inventing the wheel, or converting the applet or starting from scratch, I found this amazing video tutorial which talks you through how to build it in about 1 hour:

Here’s the game in playable form

Write a Falling Blocks game in javascript

Click here to play the game.

Bugs and changes

  • Change – I added detection for the ‘up’ key – so that would rotate it not just the rotation keys.
  • Bug – With not enough colours (1 too few) some of the blocks were disappearing then reappearing, by making sure the number of colours was correct this fixed the problem – and the block string
  • The blocks were sometimes falling through the bottom – that was because I needed to replace the drop code with ‘playerDrop();’ and that resolved the problem

Thank you

Thank you to ‘Meth Meth Method’ for providing the tutorial video and helping me develop the code from your tutorial!

What’s next

On the to do list now is a sonic or mario style platform game, a Pac Man or ‘Oh Mummy’ style collection game, a outrun type racing game. I’d also like to create a version of a board game (one of the those escape room ones).