views:

84

answers:

1

So I'm making a game where an @-symbol jumps from "roof" to "roof." The roofs are made up of _ and |.

Can you check my overall structure of the program. This is what I have so far. I can post the code if it helps.

  • App Class - This holds the main file, asks for the players name, and creates/passes a Player object to the Game class.
  • Player Class - The player has a name string; Runner object; and a Roofs object.
  • Runner Class - The runner has the runners coordinates, score, level, and count.
  • Roofs Object - The roofs object as a 2D array that keeps track of all the roofs.
  • Game Class - In here, I first build a 2D array window that will hold and print what the game looks like.
    • This is done by combining the standard window edges with the roofs array (where the buildings are) and the runner location (where the runner is). (I'll eventually add functions that will move the roof array left and create new buildings, and move the player up and down.)
+1  A: 

You might instead consider a Model-View-Controller design, as suggested in this much less ambitious example. Your model would maintain the state of the game, while the view renders the action as the model evolves over time and via user input. Separating the model and view looks a little more complicated at first, but it's easier to maintain as the project changes. For example, adding a scoreboard and status display are just different views of the same game model.

This somewhat more complex game, which models a player moving on a grid, was designed to illustrate the same concepts.

trashgod