UbGames

Elements of Game Programming

elements

Computer games push your computer to the limits.  In fact, a good computer game must excel in many areas.  To write computer games people will want to play, you must gain some expertise in the related areas of programming.  These areas represent the elements of game programming.

  • Game design
  • Graphic design
  • Controlling your game
  • Image handling
  • Sound generation
  • Making the computer think
  • Game testing

These game-programming elements overlap to an extent.  For example, to learn graphic design for computer games, you need to know how a computer handles graphic images.  Also, game design draws on all the other elements in the list.  Ultimately, you cannot design a game unless you know how the graphics, sound, controls, and computer algorithms fit together to form the final product.

Game Design

Many things determine whether a game is fun.  The most important thing, of course, is the game’s concept.  Often, a game concept is based on some real-world event or circumstance.  For example, chess – probably one of the most popular board games of all time – is really a war game.  Monopoly, on the other hand, is a financial simulation in which players try to bankrupt their competition.

Computer games are no different from their real-world cousins.  They too must have some logical goal for the player and – with rare exceptions – be set in some sort of believable “world”.  The world can be simple as a maze or as complex as an entire planet.  Whatever type of computer world you envision for your game, it’s imperative that the world have consistent rules the player can master.

Of course, to build a logical, fair, and effective gaming world, you must draw on all your skills as a programmer.  All the areas of programming come into play, graphics, sound, interface design, computer algorithms, and more help determine whether a game is ultimately fun or just another boring and forgotten game.

Graphic Design

Like anything else, graphic design is a professional skill that takes many years of study and practice to master.  Luckily, you don’t have to be a graphic design whiz to create attractive game screens.  You can look at other games to get design ideas.  You can also experiment with different screen designs to see which are the most attractive and which work best with your game.  Use your favorite paint program to draw layouts and compare them.  The more you experiment, the more you will learn about what looks good on a computer screen and what doesn’t.

To create a successful game, you must first design it, but writing a computer game requires you to bring into play the best of your programming skills. You must think about, experiment with, and finally implement the game’s graphic design and interface.

As you implement your game, you need to consider the types of images and sounds that will bring the game to life.  But foremost, you need to create the interface using smart algorithms that will bring the game to the next level.

In the rest of this article, you will learn more about each of these game elements.

Controlling your game

The game programmer must provide some sort of interface to enable the player to play the game.

In a computer game, menus and onscreen buttons enable the user to select options and commands. In addition, the player will use the keyboard or mouse to move objects on the screen.

Having a good game interface will make playing the game as easy as possible.

View our tutorial “Controlling your game”, where we discuss various methods to handle user input, keyboard and mouse.

Image handling

Graphics consists of images that are displayed and any effects that are performed on them.

Every computer game must deal with various types of images. When you design your game, you must decide which type of images you need. These images may be full-screen background graphics, icons that represent game commands or game pieces, or tiles that you use to create a map or some other complex game screen.

Once you’ve learned to design and manipulate computer graphic images, you’re ready to take on animation. Animation is the process of moving or changing a graphical game object in some way. A ball that bounces around the screen is an animation.

Animation and game programming go hand and hand, and when using a graphical environment, users expect animation in games.

For example, when a player moves a game piece, instead of simply having the piece disappear from its current location and reappear at its new one, you might create an illusion of moving the piece in sequence to its new location.

Adding animation to your game will make it much more interesting and even more fun to play.

View our tutorial “Animating your game”, where we discuss various methods to handle animation.

Sound generation

Sound consists of any music or sound effects that is played during the game. Sound is a necessary part of any game program and thanks to powerful sound cards, many of today’s games include fabulous digitized sound effects.

Music isn’t as important as sound effects, but it can add a lot to a computer game. The most obvious place for music is at the beginning of the game, usually accompanying a title screen.

You might want to use music when the player advances to the next level or accomplishes some other important goal in the game.

View our tutorial “Adding Sound to your game”, where we discuss various methods to handle sound files.

Making the computer think

A computer does exactly what you tell it to do and only what you tell it to do, no more, no less, but to get the computer to do anything you need an algorithm.

An algorithm is nothing more than a series of steps that solves a problem. You use algorithms every day of your life. When you make eggs for breakfast, you must follow an algorithm. When you drive to work or school, you must follow another algorithm. Algorithms enable you to solve all of life’s simple (and sometimes not-so-simple) tasks.

Computer algorithms enable you to solve computing problems. In other words, to write computer games, you need to figure out how to get your computer to do things.

The challenge in many game programs is to make the computer play a game well by “thinking” about its move. The player doesn’t really want to be reminded that the opponent is a computer.  Most of us want the computer to be as human as possible, slow, unpredictable, and error prone.

Creating smart algorithms will help your game be enjoyed by many players and maybe the next best-seller.

Game testing

After you write your game, you then must test it extensively to ensure that it works properly.

The best way to test a game is to give it to a few trusted friends and watch as they play, taking notes about things that don’t work the way you expected. Remember to watch not only for program bugs, but also interface bugs, which may make your program confusing to use.

After your friends have played the game, ask them what they liked or disliked about the game.  Find out how they think the game can be improved.  There is always room for improvement.

The only way to test a game is to have several people play it repeatedly. Of course, before you pass the game on to a few close friends, you should have already played the game many times and fix any errors.

Conclusion:

Writing a computer game requires you to bring into play the best of your programming skills. 

To create a successful game, you must first design it. This means that you must think about, experiment with, and finally implement the game’s graphic design and interface.

As you design your game, you need to consider the types of images and sounds that will bring the game to life.

Adding graphics, sound, interface, and smart algorithms will help your game be enjoyed by many players and maybe the next best-seller.

The end of this article is the beginning for you. Hopefully, you have found the information in this article to be valuable. If you have any comments regarding this article, or would like to make a request of any games you would like to explore, please contact us.

ubgames

Elements of Game Programming