Making a Clock

 First project with Torque Game Builder

In this lesson we will be making an analog clock that keeps track of time. We will also change how fast the time passes by four buttons that multiply time. The final version will look like the picture to the right. The images for this tutorial can be found here.


Images.zip

 

The first step is to make a new project with Torque Game Builder. After you have done that add all the images in the .zip folder to your project. You can add the images two ways: clicking the create new image map button under the create tab or open a file explorer and drag the images into the static sprites tab. The Time_Multipliers image needs to be celled. To cell the image double click it and change the image mode to cell. Change the X Count to 4. This separates the image into 4 equally sized frames which we will use for different object.

Now that the images are all added drag in the white background and set its properties to the following: Position 0,0 Size: 100,75. This will stretch the image to the size of the camera and position it in the center of the screen.

The two hands will keep track of the time. Drag in the hour hand creating a new object. Mount this object to the center of the clock by hovering your mouse over the object then click the mount button.


We need this hand to rotate with the passing of time. Turn off the track rotation under the mounting tab. This will allow to object to rotate independently from the clock object. Next let’s simulate the passing of time. Under the physics tab set the angular velocity to 30. This will automatically rotate the clock hand thirty degrees per second. Press the play scene button to run the game and you should see your clock hand move.

The second hand is the minute hand and it needs to move 12x faster than the hour hand. Add a minute hand object and mount it to the center of the clock. Set the track rotation off and set the angular velocity to 360. Run your game and it should simulate a clock.

 

 Previous Page

Quick Dev Resources

Absolute Beginner's Guide

Torque Game Builder Tutorials

Graphics Tutorials

Audio Tutorials

 

Powerful TGB Resources

Torque Script Interactive Tutorial

Sync Reloaded and Hands on Coding Guide

Copyrite Making Indie Games 2010