Game Programming – The Basic Structure And Elements of a Game Application Program

Google+ Pinterest LinkedIn Tumblr +

Video games are probably the hardest programs to write. A game program is very complex and every part is a piece that needs a lot of work in itself. What makes it different from any other kind of program is that every piece of the program will contribute to what will be displayed on the screen, how it will sound, or how a player can interact in the game. A game application is basically just a continuous loop that repeats commands like taking the player input, calculating an object’s geometry, performing collision detection, computing artificial intelligence, and presenting the scene. There are certainly a lot of things that goes in to a game program. That is why anyone would easily get confused and wonder how and where to begin with.

Knowing how a game application is composed is a good start for someone who wants to know how to completely make a video game. Game development is a very long process and you have to know exactly how every piece of the program is made and how it should fit to the entire structure. Nevertheless, you should start by building the basic structure or framework of your game program so that you could start adding all the elements and pieces that make up your game.

The following summarizes what typically compose a game application:

1. Initialization. This is the first few codes of your program. These codes are performed whenever a player runs your game application. This is where a window or an interface is created that will contain the main screen of the game. Then, the graphics, sound, and network interfaces are initialized. This is also where global values are initialized, memories are allocated, resources are loaded, and your default game configurations are set. Some games have an options menu displayed before the game starts in order to allow players to change the configuration settings. The code for this menu can be placed in the initialization part of the program.

2. Main Game Loop. The start of the game loop is where all the action begins and where the application starts to prepare all the necessary things that go into the presentation of the next frame. After the next frame is presented, the game loop continues until the player decides to exit from the game. What happens throughout the game loop is determined by the current game state. A game state could be anything such as menu navigation, a level, or a cut scene.

3. Player Input. A mouse, keyboard, joystick, or a console game control device is necessary for a player to interact in a game. A game can not be a video game if a player can not control his characters in the game with an input device. The player input section of the game program is where the player input is retrieved and processed or buffered to be used in the game logic and AI section of the game.

4. Game Logic and AI. Most of the codes to be written in a game program are contained in this section. This is where all the creativity of a game developer is put in. Everything from plot to concept and gameplay will be written code by code in this very massive section of your game program. This is where your game design will be brought about into reality through physics system, artificial intelligence, collision detection, vector and matrix calculations, and effects system. The processes that will be performed and the codes that will be executed in this section will depend on what the current game state is. Say for example in a classic style RPG, if the character is walking on the “World Map” field, collision detection is performed between the character object and the “World Map” object. If the character encountered enemies along the way, the game state will shift from World Map to Battle Event and turn-based computations are performed in the game logic.

5. Rendering of the Scene. Once the game logic section has finished its calculations, the output is brought to the rendering section. Every object in a game has its own corresponding set of data that represents its coordinates, orientation, movement, animation, and its interaction in the gameplay. This data will then determine how a polygon, or an image surface, or the effects associated with the object will be displayed on the screen. Rendering can be done either by using a software-based engine or by using hardware through HAL (Hardware Abstraction Layer).

6. Shutdown. This set of codes is executed whenever a player decides to exit the game. Before a player can completely exit from the game, all the resources are released, memory is deallocated, and the system is cleared from any temporary data. Enforcing a proper shutdown for your game will help keep every user’s computer healthy.


About Author

Leave A Reply