2011/03/22

How to Write Tetris

I'm starting a series of articles on how to program basic, 2D video games, with the object of focus being the game of Tetris. I'm going to try to be as language agnostic as possible, but certain parts of this project are extremely OS and programming language dependent. So far, I plan to do the articles in seven parts:

  • Part 1: Timing - Making the "game loop" is something that trips up a lot of new programmers. The game loop is a constant feature of your game project, so getting it right is important. There are a number of ways to do this in a variety of different languages; I'll show you the most common ones.
  • Part 2: Basic Graphics - You're not going to get very far if you can't draw something on screen. We'll focus on 2D graphics APIs, as there are plenty to come by that are more than suitable for this task.
  • Part 3: Tetris Logic - I'll go into detail on how I have decided to implement basic "Tetris" logic, and my motivations for doing so. There are any number of ways to do this.
  • Part 4: More Advanced Graphics - The graphics we did in Part 2 are serviceable, but not pretty. We'll learn how to leverage free tools for drawing tiles and backgrounds that can really punch up the look of your game while remaining very simple to implement.
  • Part 5: Sound - The sounds requirements for such a simple game are very limited, so this is only going to cover some basic points.
  • Part 6: All The Trimmings - At this point, the game should be playable, but we won't have any of the "trimmings", e.g. menus, game over screens, score tables, options, etc. Here, we'll go over what users typically expect out of their game experiences and how to implement them in a way that is robust and easily expandable.
Along the way, I'll be pointing out different areas of programming best-practice that often only come out of many years of experience. I've been programming professionally for over a decade, so hopefully you can learn from my past mistakes and get off on a good footing.

0 comments: