Game Objects

Game Object Guide

Game Objects in Game Programming

A game object is any object in a game that the player can see and/or interact with. The player object, power ups, enemies, platforms, walls, weapons (if collision detection is considered) and projectiles are all game objects.

Depending on the capabilities of the programming language that you are using, a game object may or may not be constructed in code as an actual object, as in the case with object oriented programming. However, no matter what programming language you are using, all game objects are constructed from a number of variables, subroutines, and functions that give the game object it's qualities and capabilities.

Creating Game Objects

How you create your game objects will depend on the programming language you are using. However, the following description of game object programming assumes only that your programming language has variables, types (or structs), and some kind of user-defined subroutines or functions. These features have been standard in programming languages for almost two decades and if yours doesn't support these features, you may want to consider finding a new programming language. If you are using an object oriented programming language, such as Brutus2D, you will be able to easily transfer these concepts to OOP.

Game Object Qualities

Game objects have qualities, that is, information about the game object that your game engine needs to interact with that object. For example, in a 2D game, the most basic qualities (properties, in OO lingo) is an object's horizontal and vertical location. Qualities such as these are contained in variables. Almost always, the variables x and y are used to hold an object's horizontal and vertical location. Without them, your game would have no way of knowing where the object was.

Other examples of qualities that a game object may have is damage capacity, such as hit points, and damage rating, which is how much damage a game object is able to inflict.

Types are used to put all of these qualities in an easy to manage package. Here is a FreeBASIC example :

type playerObject
    x as single
    y as single
    hitPoints as integer
    damageRating as integer
end type