Select Page

Programing a video game is not as difficult as it seems. Indeed, with some simple fundamentals, it is possible to create a fully playable video game. Alexis Kuperfis explains us the different fundamentals to master.

Five fundamentals for programing

First of all, in order to program a video game, you have to know how to store values and make calculations. To do so, we use some variables (number of lives, enemies, etc.) and some expressions. They all are stored in the memory of the computer, which will have to make some simple calculations (addition, subtraction, etc.) in real time.

Then, you need to be capable of performing some repetitive tasks. For instance, loading the level, returning the character to its initial position, etc. In order to program these repetitive tasks, we use functions.

It is important to make your program smart, otherwise it is linear and always does the same thing. To do so, we use control structures: conditions, loops.

It also essential to manage data groups such as lists and boards. They are mainly use to manage the game map (position of houses, roads, etc.). Finally, it is necessary to organize the code by theme or by role.

 

Five fundamentals to create a video game

Thanks to the first five fundamentals, we know how to recreate the intelligence of a video game, but not how to bring it to life. To do so, it is necessary to use a game engine.

First of all, you need to be able to display images, that is to say, loading and displaying an image.

Then, thanks to variables, you have to move this image on the screen.

It is also important to animate an image. Change its position in real time, when we press a key on the keyboard, for instance. Rotate it or change its size.

To bring even more reality to your video game, it is essential to add sound. A few lines of code are enough to play sound effects or music at given time. The sounds are pre-loaded in memory because they must be activated quickly at a specific moment when music will be stream to avoid cluttering the memory.

Finally, the last and most important of fundamentals is interaction. The commands entered by the player using the computer mouse, keyboard or controller must be recognized by the video game in order to react accordingly.

Thanks to these fundamentals, it is possible to create small 2D video games, completely playable. For instance, it is totally possible to program a game such as PAC-MAN using these kinds of fundamentals.