Javier Lopez wrote a beginner’s tutorial to write Tetris in C++. NOTE: It seems this link is broken. I’ll see if I can find a replacement. The tutorial is platform-independent, which I like. While some people have complained that the tutorial isn’t very good C++, I’ve yet to see a more comprehensive and complete Tetris tutorial. Once you’ve followed it and written your own, feel free to spend the time to write a better one.
Full disclosure: I’ve never written a Tetris clone.
WHAT?! Haven’t ALL game developers worth their salt made their own Tetris? Didn’t icculus say that it was good for the soul?
I’m not going to say that I’m proud of it, but for some reason the furthest I ever got was to write some notes down. I would think about how to represent the various pieces, but I would get hung up on not easily seeing a general way to do so. I could have hard-coded them the way the tutorial does, but I thought, “Nah, I can do it better than that!”
But then I never did it. And so I never wrote a Tetris clone at all.
For new game developers out there, you have to realize that shortcuts and brute force methods are perfectly fine sometimes. It’s more important to get something working, even if it is working badly, than it is to get it right the first time. Otherwise, you spend years tweaking a general purpose game engine.
Lopez’s tutorial will do more to help someone understand basic game logic than most game engine tutorials, and the end result will be a pretty good clone of the original Tetris. The player isn’t going to care that you didn’t use every bit of functionality that C++ (or any language) provides. You made a game, and that’s all that matters.