“CLOCKS – The Game” HTML5 prototype step 2: how to select starting clock

Welcome to the first post of 2016. We’ll continue from the last 2015 tutorial about the creation of a HTML5 “CLOCKS – The Game” prototype using Phaser framework and ARCADE physics.

In first step I showed you how to generate the first 10 levels, both with objects and with arrays generated by Tiled Map Eeditor.

Now it’s time to add another feature to the game: randomly selecting the starting clock. Moreover, the starting clock has a different look, with another color and a visible clock face.

From now on, I will also use levels generated by Tiled, but you are free to generate yours as you want.

I had to turn some flat images into sprite sheet to store normal and highlighted clock status in a single file, and same thing goes for the hand.

Highlighted clocks were made using a dark gray as I will tint them according to level tint color.

When a level is generated, each clock I create is stored into an array, so selecting the starting clock is just picking a random element in the array.

Then it’s just a matter of tinting some sprites and showing some other sprites.

Have a look:

Each three seconds a new level is generated, and a random clock is chosen as the starting clock.

Here is the source code, still uncommented as it’s just in an embrional stage, but with next step you’ll be able to play the levels.

You are closer to see how easy is to create the final game – I will also add more levels – thanks to Phaser and Arcade Physics. Meanwhile, download the source code.