Tutorial: Game Structure
This tutorial will introduce you to the basic code structure most games follow.
Basic Game Structure
The basic game structure games use is divided into three sections :
- Initialization, get the game going
- Game Loop, main game code
- Termination, end the game.
Here's what it looks like in a very simple example :
; Initialization ------------------------------------------------------
SetFPS 60
; Game Loop -----------------------------------------------------------
Do
Cls 0
Print "I am your obedient and loyal robot slave."
Sync
Loop
; Termination ---------------------------------------------------------
; Well, this is where you would have a termination section. :)
Initialization
Initialization is where you get your game going. Anything your game needs to run will be created / loaded here.
In our example, we only do one thing : Set the game speed to 60 frames per second.
SetFPS 60
Main Game Loop
Everything between Do and Loop is your main game loop.
The code inside this loop will repeat until the game is over or you press the ESCAPE key.
The game loop itself has it's own tutorial where it is covered in detail.
| Categories: Beginner Tutorials : Tutorials |