Sunday, March 17, 2013

Building Breakout In 3 Days - Day 2

As I mentioned in my post yesterday, I've received an assignment: Build a clone of the classic game Breakout, using only C++ and either DirectX or OpenGL, no game engines or editors. I plan to do this in only 3 days.

Progress To Date

Yesterday, I combined my DirectX project from last semester with one of my C++ game demos, removing unrelated code specific to those projects and 3D code from the DirectX project. This took quite some time, and the DirectX 2D code still needed to be tested (to make sure I hadn't removed anything vital by accident).

The goal for today was to get the basic gameplay implemented, minus level loading and any frills. Those would be tackled tomorrow.

Creating the Title Screen

I decided to create the title screen first, along with a button that will progress to the next screen. This would allow me to make sure my framework was working properly before moving on to more complex features. In fact, I got the idea that making the title screen into an extremely simple level might be a good way to teach the player how the gameplay works.

First, I created a very simple title screen image, including the game title, my name, and instructions on how to play, as well as a mock up of where the button would go when complete.

Mock up of title screen.
The next test was to see if my new graphics API was working. Unfortunately  it wasn't - I had gotten rid of the camera class but actually needed it to set up my view matrix. This was easily enough fixed, and soon I had a scaling title screen placeholder.

Then, I needed to get the title screen worked into my screen framework. This meant determining how my game objects and logic would work with the graphics API. I decided to convert my graphics, input, and sound handlers into singletons so the various parts of my program could easily use them.

Once the basic background image was working with the screen framework, I added in the player paddle and clamped it to the confines of the play field. Then I added the ball, initially moving with the paddle until the player clicks the mouse button.

The next step is to implement collision detection with bricks and walls. Collision with the paddle would be handled slightly differently to get the Breakout feel (hitting the side of the paddle causes the ball to bounce in that direction, rather than being based on the incident angle). I had a bit of trouble with this at first, with bugs for corner cases (literally), but managed to get it all ironed out after a bit of thought.

I also added a respawn function to the ball, which re-attaches it to the paddle so it can be fired again. I added a trigger for this when the ball leaves the screen to the bottom. During an actual level, this will reduce the player's life by 1. But for the title screen, it simply respawns with no consequences.

Next Steps

By the end of the day, I had all the basic mechanics in the game - input, the ball, and collisions. Tomorrow I'll be adding the following:
  • Hitting button blocks transitions between screens
  • Sounds for ball collisions (based on the material being hit)
  • Sound for ball being shot from paddle
  • Outline for high scores screen
  • First level with test blocks
  • Blocks that break when hit
  • Sound for block breaking
  • Orange blocks take two hits
  • Orange blocks change ball color to one of several random colors
  • Red blocks take three hits
  • Blocks show their damage via cracks
  • Lives and a game-over state
  • Score increased by breaking blocks
  • Level loader and pre-created levels
  • Three total levels
  • After three levels are complete, game cycles, increasing ball speed each time.
  • Score recorded in file for high scores (name entry?)
I may not get to all of this, but I hope to. The basics are already in, the only really challenging things to come are the level loader and high scores system, the latter of which is not even necessary as per the brief.

No comments:

Post a Comment