Experiments In Game Programming
Main
 Home
XNA - C#
 Coming Soon!
 Level Editing - GTK
DirectX 9 - C++
 Downloads
 Disclaimer
 Introduction
Part 1 - DirectX
 1 - Breakout
 2 - Create DX
 3 - 2d Images
 4 - 3d Models
 5 - Cameras & Lights
 6 - Animation Timing
 7 - Keyboard/Mouse
 8 - Sound
Part 2 - Breakout
 1 - Art and Sounds
 2 - The Menu
 3 - Starting Breakout
 4 - The Level
 5 - The Paddle
 6 - The Ball
 7 - Finishing Touches

Untitled Document

Chapter 1

 

Breakout, the Why and the What.

 

 

Topics Covered in this chapter:
  • Breakout?
  • Why Breakout
  • Elements we are going to need

3d Breakout?

Almost everybody at some point has played the game breakout, or at least something similar. If you haven't it's easy to find a free one to try out on the net. We will be writing a 3d breakout clone. We won't actually be adding any depth to the game, but all of our game components will be 3d objects instead of 2d sprites. Game wise this doesn't actually add anything to the game, but it serves as an excellent way for a beginner to be introduced to the 3d components of DirectX.

Why Breakout?

It's a good question, with an excellent answer. All games share certain key functionalities, a game loop, player input, update based on game logic, and display output. They all check for win and loose conditions, often keep score, and generally have multiple levels. Breakout has all of those elements, and it is also simple enough that a single programmer can accomplish the entire game in his or her free time. Starting with something simple yet complete like breakout means that when you move on to something more complicated you will find much of the basic concepts to be the same.

What do we need?

Well lets talk through a game of breakout and see what it needs. Before any game begins there is usually a menu of some sort, usually with a flashy title and options for starting and exiting the game. So assume we have a menu, and assume it has a 'New Game' option. When you select the new game option the menu disappears and the game screen is displayed. There is a brief countdown before the game begins. Once the game begins the ball begins falling at a random angle. The player has control of the paddle, and uses it to deflect the ball. The ball then bounces off the paddle, and up into the bricks, as the ball bounces off the bricks it destroys the them. When all the bricks are destroyed the level is complete. If the player fails to deflect the ball he looses a ball and a new ball is provided. If the player looses a certain number of balls the game is over. When the game is over the high score screen is displayed and if the player has scored high enough they get to enter their name onto the scoreboard.
  • A Window - Since we are developing this using DirectX we will be running in windows, and the first thing we need is a window for our game.
  • Draw Images - If we are going to have a flashy menu, we are going to need to be able to draw Images.
  • A Game Loop - Something to make calls to process input, run game logic and update our display.
  • Get Input - The player can't control the paddle unless we can input from the keyboard, the mouse, or somewhere else.
  • Draw 3d Objects - Because we are making a 3d breakout clone, the ball, bricks and paddle will all be 3d objects.
  • Timing - The game needs to run at the same speed on every computer it is played on, we can use a timer to do just that.
  • Play Sound Effects - The game really isn't complete without annoying sound effects.
  • Store Levels - The level needs to be loaded from somewhere.

That's definitely not everything, but its a good starting point. Part 1 of this book is going to cover setting up interface classes to do everything listed above, minus the last item. Storing levels, will be covered in Part 2 when we begin implementing the game.

 


 ©2008 David Whittaker