A Project Completed!

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.

7 comments to A Project Completed!

  • Peter Mackay

    “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! 🙂

  • Peter: This project is the first one in which I had to encounter memory management on such a scale. I was thinking about how useful it would be to use auto_ptr or something similar so that I didn’t need to worry about it, but part of my problem was that I left pointer deletion to the end of the project. I didn’t know who would end up owning what, which probably indicates a problem with my design…or lack thereof. B-)

  • Peter Mackay

    Hehe, I’m also a design-by-hacking-together kinda guy. I would have gone insane without smart pointers, not sure why they’re not more widely used.

  • Before I get flamed, let me state that I cant even program a VCR let alone a game. With that said, I would like your input on this question:

    Once C++.NET is available for Linux will you use it? I understand that managed code can cut way down the need to worry about memory management. Also, wont the DirectX API be available as well?

    Just a newbie question….

  • epic: While managed C++ might become available on Gnu/Linux platforms, the DIrectX API won’t likely be available. I already know that some projects rely on Mono, so some version of .NET is available today.

    One of my goals would be to utilize all FOSS in my development work, so even if the DX API was available, if the implementation wasn’t, I would have to decide against using it. It’s a self-inflicted impediment, I know, but part of the fun is challenging the idea that in order to make money, you need to use proprietary software.

  • GB – I just think you’re being stubborn 😉

    Congrats on finishing the game though!

  • Hehe, thanks Keith. B-)