C Game Programming Made Easy

cgameprogrammingWriting a game using C isn’t as difficult as it seems. However, the reason so many people make failed attempts at it, is because they haven’t taken the time to preplan the game elements or interface before beginning. This results in glitches, invalid codes and a poor game design. When using C to program your game, you should keep the following gems in mind to help you make the best of it.

Learn C++ Game Development in this online course from Udemy!

Game Elements

Let’s face it, games programmed in C rock! However, if they’re not planned out well, the game comes across as boring and confusing. Before getting started you need to have an outline of the actual elements that you wish to have in the game. This will help cut down the programming time, since you won’t have to research as you go along.  Elements in the game (depending on what type of game it is) should include all or most of the following:

  • Images – Will your game be 2D or 3D? Your graphics really should include everything the player is going to be looking at throughout the entire game.
  • Audio – Any sound effects, background music or environmental effects.
  • Story – Here’s the fun part. What is the main point of the game? Create a storyline that will capture the player and also explain to them the point of each level. This storyline can appear at the beginning of the game or anywhere else you want to inject it.
  • Levels and Length – How many levels will the game have? How long is each level? How long is the game in total.

Determining Your Game’s Interface

In order for your game to look like one that Sony would want to purchase, you have to create a killer interface. The interface should include information such as how many players there will be, an area to type in their names and a display of player information. Player information includes scores, who’s turn it is to play and wins or loses.

Programming Examples

Now we get to a little programming.
Let’s say you created a 2-player game, you would need two variables. These variables would allow each player to program their names before playing and select their plays. Here’s an example of what that would look like:
char name[2][30]; //double dimensional array to store names of the player int chance; //to store the chance, to track which player is to enter the move

Botskool, provided a great example of what a graphics code would look like. This code is to create a player A and player B game with scores, bats and a ball for each player.

Creating a game with many graphics and levels could be a bit difficult for a beginner.  If you are a beginner and you aren’t sure of where to start, consider taking this courses: