Retris lives. Gosu rocks. Object thinking prevails.
I pushed the first version of Retris to github about ten minutes ago. It feels pretty good.
- Retris screen cast (large version)
- Github repo: http://github.com/angryrabbit/retris/tree/master
- gosu library
There are quite a few missing features, but it’s playable. There are probably a small handful of bugs. I’m only aware of one or two. Both are documented in the readme.
I want to thank Julian Raschke and the other gosu contributors. I love Ruby and it’s awesome to be able to concentrate on my game rather than dick around with low-level details.
As happy as I am that I’ve “finally made a game”, I have to confess, I don’t care for Tetris. I suck at it, too. I wrote it because I read in an old game programming book that Tetris is a good first game.
So what’s next? Well, I have a few things I want to finish up. As Diana Gruber says, “the last 10% of the game takes as long as the first 90%”. Or something like that.
At the very least I need to instate loss conditions. Currently, overflowing the grid simply causes the game to go on a freak rampage, creating shape after shape in the grid’s origin. It doesn’t crash, but you can’t do anything but exit when you reach that point.
I’d also like to put in a menu, pause feature, difficulty levels and a menu.
When those things are done I’ll start to think about another game.
I’d like to point out that I ditched the idea of using a matrix (nested arrays, actually) to model either the grid or shape objects. I made this move for several reasons:
- Nested arrays require some math
- I can’t ask a nested array meaningful questions
- Previous attempts at using nested arrays fell short for me
- It doesn’t feel very object oriented
There’s no doubt in my mind nested arrays are a viable implementation to Tetris, but personally, I prefer objects.
True, I could have wrapped the nested arrays into an object and queried that, but it’s just not decomposed enough for my tastes. My landscape (objectscape?) includes Grid, GridLocation, Cursor, Shape, Location and Block objects to orchestrate the interactions required of Tetris. (There are a few more objects, but the ones I listed are my solution to NOT using nested arrays.)
Similar to my object-oriented solution to the Tower of Hanoi, (portions of) my code read like a story. Stories are easier to grasp than mathematics. At least for now they are. I’ve decided to go back to school primarily for math.
I imagine though, that even as I become more proficient with math, the “stage” my code lives in, and the messages passed back and forth, will remain largely true to my current style.
In fact, if object-oriented programming is really all it’s cracked up to be, my style will only get tighter and more nuanced; only the implementations will change.
Five years from now I just might use an (actual!) matrix object to handle the implementation for Tetris interactions. But, my guess (indeed, my hope) is that the act of sending messages to create a story will remain in force.
Here’s to the human mind.