Search code examples
allegro

Review my game project OR (How to peer-review my project)?


I just finished a 2d platformer in C++/Allegro. Its still in an incomplete stage...

I wonder how to go about a peer-review from people who are into game development. I would like to review my project on grounds of

  1. game play
  2. Collision detection
  3. use of OOP
  4. programming of sounds, effects etc
  5. any further ideas
  6. ways in which i could have done better
  7. ways to optimize

current code looks like a garbage at some places... so could you also suggest some simplification techniques?

you can view my project (if you wish) at updated link - nincompoop (direct link)

http://ideamonk.googlepages.com/nincompoop_distro.rar

As of now I am switching to C# and XNA, finding it very easy and fast to learn all because I'm impressed from -

http://catalog.xna.com/GameDetails.aspx?releaseId=341

I do no intend to sell any product or popularise anything here... my intent is to get tips to be better from people who are better. As for the page where I have uploaded my project, its not supported by ads of any kind. so please feel safe.


Solution

  • The first thing I noticed in your source code is that you've got most of your game logic is in the main.cpp file, with the nesting going as deep as 11 tabs! For code organizational purposes, this is a nightmare. Of course, I did this too on my first game. :) The first thing you can do is simplify your main game loop to look something like this:

    int main () 
    {
        game_object gob;
        gob.init_allegro();
        gob.load_assets();
        while(true) {
            gob.handle_inputs()
            if (!gob.update())
                break;
            gob.render();
        }
        gob.cleanup();
    }
    

    Everything else should be refactored into your game_object class. It will be much easier to manage this way, also your code might actually fit on the page since you can avoid deep nesting. If you find your code getting more than 3 tabs deep, then whatever you are doing needs to be refactored into another method or even a separate class.

    My second suggestion would be to replace your goto's with something a little more sane like this:

    bool playerwins = check_win_condition();
    
    if(playerwins) {
        // win condition code
    } else {
        // lose condition code
    }