Chapter 1 – Game Logic

Since I’ve been hit with Coder’s Block, and am not in the mood to write code myself for some time, I decided to do a series of block posts to teach other people some game programming.

Now, Let’s see. Where should I start?

Okay. The first thing an emerging game developer must know, is the difference between the Game’s Interface and the Game’s Logic.

Game Interface

This includes all the graphics and animation code, along with sound effects, user interface components and getting user input. Basically all the stuff the game utilizes to communicate with the user.

Game Logic

Game logic consists of Artificial Intelligence code, handling the game input, generating events and responses, timing the game’s events, generating and parsing tiles, game physics, collision detection and all the other odds and ends that make up the game.

Now, the important thing here for a game developer is to differentiate between game logic code and game interface code. It is a good idea to separate the Game’s Logic from the Game’s Interface (google “MVC”).

The Game Loop

Most game’s run in a while loop, something along the lines of

while (Game.IsOpen())
    Game.GetInput(); // From the keyboard, joystick etc,
    Game.Update(); // Respond to the input and handle time based events
    Game.Draw(); // Draw the game interface and sprites etc.

Now that you’re acquainted with a game’s skeleton, let’s head on to writing some real code in the next chapter.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s