projects

Team Project: 2D Scrolling Shooter

Falling Block Fun

Executable File

Source Code

For now, my project list is short. I have recently completed a Tetris clone called Falling Block Fun, using C++ and DirectX. I picked this clone as my project because, compared to anything more complex in 3d, it was relatively simple program to start with, and I could use the original game to help me with the design (i.e. reverse engineering).

Before I started any coding, I decided that I needed to research exactly how I was going to display graphics and program the game. To do this, I found a group of DirectX tutorials and started playing with those. In addition, one of my friends (Pat) lent me a book on the Windows API. Once my research was complete, I sat down and put notes on paper so that I could better understand how the game loop would work. After that was complete, I used my limited Photoshop knowledge to design a menu screen. The menu screen highlights either start or exit. You can change from one to the other by pressing the up or down arrows. Then, you can press enter either to exit the program or enter the game, depending on the option selected.

For the second phase of the project, I built the actual game screen (once again in Photoshop). Here is an example of the screen:

Falling Block Fun Screen

For the blocks themselves, I designed a block object. The block object has several methods assigned to it (e.g. move, drop, rotate, etc.). The individual shape objects (T-shape, L-shape, etc) are children of this object. For troubleshooting purposes, before I even coded the child objects, I made it so that one block would fall by itself on the screen. This was so that I could test the move and drop methods. After I had corrected some of my bugs, I started to build the shapes. Which is when I faced my next challenge: rotation. Just like before, I wrote out small grids for my shapes on paper to get a better idea of how I could code the rotation for each. I ended up going with two separate arrays - one for the active shape, and the other for the rest of the grid. This allowed me to keep track of my active shape without disturbing the rest of the grid.

After all of the pieces were animated, I added text so that the player knew what the controls were, and had some indication of how many lines they cleared. Going along with that, I added code that would increase the speed once a certain number of lines were cleared. The last thing I added was a game over screen.

What went right

Paper prototypes: My paper prototypes were possibly the best thing I did during the project. They help me map out the most difficult parts of the project and gave me a good plan of attack when I finally sat down to program.

Up-front research: Researching the tools that I would need to complete the project beforehand also saved me time.

Asking for help: The book that I was lent for the Windows API, plus Pat's advice helped me finish the project.

What went wrong

Not testing the game enough: When I posted the game and the source code the first time, there were two bugs that I did not catch. The bugs did not show immediately, so I didn't notice them until I conciously tried to break the game. The worst part about that is that I was giving out business cards with this website on them during the Austin GDC. I will never know how many people have seen that buggy code.

Conclusion

The purpose of this project was so that I could learn how to write a basic game using C++ and DirectX. Feel free to make any comments about the project or some of the design decisions I made. The compiled code and a copy of the source code is available at the top of the page.