Chapter 3: Writing Games


Highlights

Computer games are one of the most exciting Windows applications to write and are at the same time one of the most difficult. Modern games, such as Quake or DOOM, also usually consume a lot of computing resources and normally require the most powerful processors to run. More important, you must write each line of the code by considering efficiency, even if this means more memory will be used. Speed is more important than memory! For this reason, not surprisingly, C and C++ have been the two languages of choice when developing computer games. For speed, speed, and speed.

Writing popular games is even more difficult. Not only do you need to be a skillful programmer, but popular games are more the child of high creativity and imagination than technical expertise. The figure is something like this: Out of 10,000 game developers, 9,900 go bankrupt because they do not get the required market acceptance. In other words, their games are not interesting and exciting enough.

Now, before starting, I would like to say the following in relation to your expectation: This chapter explains how a computer game works. However, it does not have the pretension to make you a commercial game developer. Also, it does not provide you with the techniques required to write games that can compete with the most modern games. Therefore, you will not be able to write Quake just by reading this chapter.

The main objective of this chapter is to teach how to write multithreaded programs using the classes in the System.Threading namespace. A game application is selected as the project to make the learning process more fun.

Not only that, but games, even simple ones, are exciting. A game is very different from the rest of the projects in this book. Testing the project, for example, means you need to play the game. And, you also play the game when you are debugging. How fun is that?

And, did I mention creativity and imagination? I must confess I am not a person with much of each of them. Therefore, for the project, I clone a simple popular game that you have probably played before: Pac-Man.[1] For those of you who have not heard about this exciting game, the following is a brief history of Pac-Man.

Pac-Man was one of the most popular games in the early and late 80s. It was the fruit of Toru Iwatani's imagination and creativity. Iwatani worked as a game designer at Namco Limited, a video game company in Tokyo, Japan. Born on January 25, 1955, Iwatani is self-taught, never having any formal training as a game programmer..

Iwatani joined Namco in 1977, at the age of 22. Three years later, he thought of Pac-Man for the first time, when one day he was eating a pizza. He ate a one slice and the shape of the remaining pizza gave him the idea.

With the help of four other Namco employees, Iwatani completed Pac-Man in one year and five months. The game was first introduced in Japan, where it became an instant success. It then invaded America and Europe in no time.

Note

If you are interested to know the story behind Pac-Man's invention, this is a useful URL: http://retrogamer.merseyworld.com/iwatani.htm.

The Pac-Man clone you will build in this chapter is called Doggie. The idea is simple. Doggie is a shy dog who is afraid of cats. So, all his life he has to run from the four cats who like to bully him. There are magic bones, however, that can help Doggie gain strength and confidence. For a few seconds after Doggie eats a magic bone, he will feel confident and brave and stronger than the cats who chase him. In those few seconds, the cats change to a paler color and Doggie can chase them to get more points. After the few seconds elapse, Doggie will lose its strength and courage and has to run away again until he finds another magic bone.

[1]PAC-MAN 1980 Namco Ltd., All Rights Reserved.




Real World. NET Applications
Real-World .NET Applications
ISBN: 1590590821
EAN: 2147483647
Year: 2005
Pages: 82

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net