At the beginning of March, I interviewed for a position at a company. I was asked to create a small text-based game to demonstrate how I would go about solving it. After a week, they asked to see my code even though it wasn’t finished yet. Apparently they liked it since I got the position.
Even though there was no need to complete the project, I kept working on it. Last Friday morning, I finally finished it.
It took almost two months of (admittedly inconsistent) part-time work, but I have finished a project. It was simultaneously simple and more complex than I thought it was going to be.
I used the tips from my previous post,Object-Oriented Game Design. I separated almost everything into Entity, State, and Action objects. In the beginning, I had to work on not only wrapping my head around the concepts but also code up the infrastructure to allow for it. By the end, adding a feature became as simple as creating the appropriate State or Action derived classes.
I’ll admit that I cheated a bit. For instance, when I create the game board from an XML file, I have a class that has no business populating the board with Space objects. I probably could have created a few Action classes to do it, though. PopulateBoard, AddSpace, etc.
Still, the game is finished. I spent a bit of time trying to match up each delete with its respective new. I fixed an off-by-one bug that would crash the game if you moved back three spaces and you were going to cross from the beginning of the board to the end of the board.
On the other hand, it isn’t really a “game” since there is no interaction to speak of. The players roll two dice and move according to the dice. There are no choices. Still, this simulation proves that it is easy to create games based on entities, components, and actions. I hope to translate what I learned into Oracle’s Eye and other games.










“I spent a bit of time trying to match up each delete with its respective new”
If that’s not a case for std::auto_ptr or boost::shared_ptr I don’t know what is!
Left by Peter Mackay on May 4th, 2006