4) Game Development Concepts

Back to Getting Started


The Core Game Loop Model

Most real-time games repeat the same structure every frame:

  1. Read input.
  2. Update game state.
  3. Render visuals.
  4. Present frame and repeat.
Do
    HandleInput()
    UpdateGame()
    RenderGame()
    Flip()
Loop Until gameOver

Input Layer

Input should be read every frame and translated into game actions.

Update Layer

Update is where game rules happen:

Keep update logic independent from drawing whenever possible.

Render Layer

Render draws the current state without changing game rules.

Resource Lifecycle (Load Once, Reuse, Free)

Load resources before the main loop. Reuse handles during the loop. Free resources after the loop.

Dim fontRef As Integer
Dim playerImage As Integer

fontRef = LoadFont("", 18)
playerImage = LoadImage("assets/player.png")

Do
    Cls()
    DrawImage(playerImage, playerX, playerY)
    DrawText(fontRef, 20, 20, "Score: " + Str(score))
    Flip()
Loop Until finished

FreeImage(playerImage)
FreeFont(fontRef)

Simple State Machines

Most games switch between states such as menu, gameplay, and pause. Use a state variable.

Const STATE_MENU As Integer = 1
Const STATE_PLAY As Integer = 2
Const STATE_PAUSE As Integer = 3

Dim state As Integer
state = STATE_MENU

Time and Motion

For smoother motion, many games use FrameDelta() to scale movement by elapsed time.

playerX = playerX + Round(playerSpeed * FrameDelta())

Architecture Advice for New Projects


Navigation: Previous: Programming Fundamentals | Outline | Next: Debugging and Problem Solving