Home > Articles > Programming > Games

Playing MIDI Music Through a Game Engine

  • Print
  • + Share This
This lesson guides you through the design and development of a game called Battle Office that chronicles an inter-office war between co-workers. It's not as violent as it sounds, and it demonstrates how to play MIDI music using the game engine.
This chapter is from the book

Well here you are, ready to embark on your third complete game. At this point in the book, you've successfully added wave sound effects and MIDI music programming to your repertoire of game development skills. What better way to celebrate than to design and develop another game to put the skills to good use? This hour leads you through the construction of a game called Battle Office that chronicles an interoffice war between co-workers. Don't worry: It's not as violent as it sounds. The job of the player in the game is to use the mouse to fire at co-workers as they appear in various places on the game screen. The game makes interesting use of the sprite classes, as well as wave sound effects and music.

In this hour, you'll learn:

  • How to design a game called Battle Office that simulates a battle between co-workers within an office

  • How to write the code for the Battle Office game

  • About the joys of testing a completely new game

How Does the Game Play?

I once worked at a software company where it was fairly common for balls and other objects to be thrown around for fun while taking a break from the seriousness of programming. On some rare occasions, the speed of the throws would increase to the point where an all-out game of dodge ball erupted. Sometimes the games were friendly, and sometimes they progressed to being almost dangerous. In fact, prior to me joining the company, there was a story of a guy being knocked out because someone threw a small bag of change that caught him in the head. Not a good idea! And in case you're thinking about starting your own interoffice dodge ball game, I encourage you to use soft balls and make sure that everyone is up for it before firing the first shot.

My experience hurling balls and other objects at people in my former job serves as the inspiration for the Battle Office game, which involves firing at co-workers in an office environment. The game screen in Battle Office consists of an office space with several desks and a doorway in the back. Co-workers will periodically pop up from behind their desks, as well as run by in the background through the doorway. Your job is simple: bean every co-worker who appears onscreen.

NOTE

Although the Battle Office game does simulate a battle, it's safe to say that it's a friendly battle. In fact, the specifics of what is being fired at the co-workers are deliberately left vague so that the player can imagine what is being fired. It could be paper wads, Koosh balls, rubber bands, or dinner rolls—it's up to your imagination to fill in the blank here.

If the object of the game is to shoot every person who appears on the screen, you might be wondering how you lose. Well, the Battle Office game is all about efficiency and perfection, so you are only allowed so many misses. In other words, each time a person on the screen escapes, it is considered a miss because he got away. When you run out of misses, the game ends. On the other hand, the game keeps track of how many people you successfully hit, so there is a score to keep track of how well you're playing.

  • + Share This
  • 🔖 Save To Your Account