Create a HTML5 game like iOS hit “CLOCKS – The Game” using Phaser and Arcade physics

During these days I made a couple of plays at CLOCKS – The Game by Noodlecake Studios.

It’s an one button game where you have to destroy all clocks on the stage by hitting them with a ball which is fired from clocks’ hand.

clocks

Simple but addictive, it’s the perfect game to be deconstructed to make you see how easy is to make these kind of games with Phaser and Arcade physics.

I played the first 20 levels and as far as I know, it’s a tile based game played on an 8×8 grid with two different clock sizes:

clocks

In this first part of the tutorial, we’ll see how to create the levels, both manually and using Tiled Map Editor to generate an array of data which will be converted into a level.

Here you can see the 8×8 size of the game grid:

Since most of the level is made by empty tiles, an idea would be to define arrays to store big and small clock positions, this way:

Here you can see an object representing level 3, with small and big clocks stored into arrays.

If you prefer – I do – you can use Tiled to manually draw the levels with big and small clocks, then keep only array data, like this:

And you just have to pay attention big clocks occupy four tiles while small clocks only occupy one tile.

In this example, each three seconds a level from 1 to 10 is generated, in one of the two methods mentioned above, randomly chosen:

Click on the canvas and see. Still no interaction with the level, but it will be easily added during next tutorials.

Here is the source code, don’t worry about the lack of comments as I only wanted to explain level design. You can try to understand the code on your own, or wait for next step with the explanation about the making of the clocks.

If you look closer at the code, you will see there’s more than just level design, clocks have been already created as Arcade physics bodies, with their hands running at a random direction. During next step we’ll see how to do it, meanwhile you can download the source code.

  • Franz

    Well done!Very interisting!
    There is also an ActionScript 3 version?
    tnx

    • Emanuele Feronato

      not at the moment, I am finishing the HTML5 version now, then we’ll see if there is some requests for AS3 versions