Game Development Community

How to Create Game Loop? (Torque Script)

by beyond · in Torque Game Engine Advanced · 02/18/2011 (8:53 am) · 2 replies

Hi!

Early i worked with events of objects & place my code
fragments to events callbacks.

But I don't understand very important thing - How
to Create Game Loop? Where I can place my code
for objects moving, animation, e.t.c.?

Thanks.

#1
02/18/2011 (9:08 am)
The game loop is a constantly running thing that the engine handles. You use event-driven programming to make the game logic to do new things. Each individual object you create can have scripts attached to them with callbacks for damage, movement etc.
#2
04/04/2011 (5:19 pm)
If your game absolutely needs a game loop you can create one. Call a function named "GameLoop" when the level loads and schedule a call to "GameLoop" as the last line so that the function is called every 50ms.

Ideally you would break down the game into many small loops: one for each monster walking around, one for clouds floating by, etc. You can control each part of the game independantly. You can have the keyboard polled every 75ms but the main character animated at 50fps.