4) Game Development Concepts
The Core Game Loop Model
Most real-time games repeat the same structure every frame:
- Read input.
- Update game state.
- Render visuals.
- 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.
KeyDownfor held movement.KeyHitfor one-frame actions (confirm, pause, menu select).MouseX,MouseY,MouseButtonfor pointer interactions.StartTextInputandGetTextInput$for typed text entry.
Update Layer
Update is where game rules happen:
- Position changes
- Timers and cooldowns
- Collisions
- Health, score, and win/lose checks
Keep update logic independent from drawing whenever possible.
Render Layer
Render draws the current state without changing game rules.
- Clear with
Cls. - Draw background and world objects.
- Draw UI last (score, health, prompts).
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
- Start with one file until concept works.
- Then split by responsibility: input, update, render, assets, audio.
- Keep names clear and direct.
- Avoid very long functions when learning; shorter blocks are easier to debug.
Navigation: Previous: Programming Fundamentals | Outline | Next: Debugging and Problem Solving