Game management

Started by
9 comments, last by GWDev 11 years, 2 months ago

A (classroom) way to get startet with organising your code in a OOP way would be to to write down the details of your game.

e.g. TIC TAC TOE:
There is a gameboard.

It is divided into 9 squares.

3 times 3 squares.

The game is played by two players.

One player uses X as marker.

One player uses O as marker.

The player take turns alternating.

The player with three markers in a line wins.

The line can be horizontal, vertical, diagonal.

Might have forgotten some things.

Now you start looking at the summary you have.

There is a gameboard => gameboard class

It is divided into 9 squares. => square class

3 times 3 squares. => gameboard needs to keep track of 9 squares in 3 times 3 alignment

The game is played by two players. => player class

One player uses X as marker. One player uses O as marker. => player class needs to keep track of used marker by player => gameboard needs to store the placed marker and position

The player take turns alternating. => main class / game loop needs information about active player

The player with three markers in a line wins. The line can be horizontal, vertical, diagonal. => main class / game loop needs to check condition every loop.

So gameboard class could double as main or game class.

Gets a 3 x 3 datastructure that takes square / tile object

square / tile object gets property playermarker symbol and getter and setter

player object gets properties for playername, playermarker symbol

and so on ....

And so you continue until you have everything (entities, functionality, etc.) that is in you game written down and placed in some class / function / functions file.

If you are unsure after doing that, you can upload the document / diagramm (UML) here and get feedback.

--GWDev

This topic is closed to new replies.

Advertisement