Members - Reputation: 110
Posted 07 June 2012 - 11:44 AM
I took a programming class on Java a couple of semesters ago, and decided to expand my computer programming skills by learning to create games. I purchased Killer Game Programming in Java and created this tetris clone after reading the first few chapters. The reason I am posting this to the forum is to receive feedback on my implementation. The basic game loop is pretty much taken verbatim from the book.
The way I decided to implement this was to create a 2d screen array. Each entry in the array corresponds to a block on the screen (with 0 being white or empty). I then created a class for each individual piece. The pieces are represented by four coordinates, corresponding to the relative locations of the four boxes (for example a line piece was (-2,0) (-1,0) (0,0) (1,0) ) , and a coordinate that corresponds to the position of the (0,0) box in the array. The pieces are then drawn relative to this (0,0) position.
My goals for this game were to create the game without looking at specific online tetris tutorials (to force myself to learn to think like a game programmer) and use good object oriented as well as game programming style.
My biggest annoyance with the way I implemented the game were that I couldn't figure out a clever transformation on the pieces to rotate them, I instead ended up hard coding all the different rotation states.
I was hoping that some of you with game development experience could comment on whether the way I implemented this game is a logical way to do it (it works, but for all I know there could be a way simpler way to do this) and to take a brief look at my code and suggest ways I could have better used object oriented style and game programming techniques.
Thanks for reading and I appreciate any feedback that is offered!
Tetris.zip 26.24KB 208 downloads
Members - Reputation: 2764
Posted 07 June 2012 - 02:02 PM
Your next game will be much better coded.