RE: game development layout question

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 13 Oct 2007 07:40:21 -0700

Checkers is so hard to make an object out of the game piece.  There is so
little states for the game piece I almost just want to represent it by a
bool on the game board object.  I guess if you wanted to make it so the game
logic was defined all in the piece classes so you could make multiple games
for example chess and checkers on the same board you could make it so the
game piece included rules on how it was to move and rules on what happens
when the piece reaches the other edge of the board like kinging a checker
piece.  In this way the pieces would define the game you could play.  So for
example a checker piece might be defined like this
Class CheckerPiece     {
 BoardLocation Location;
Bool Kinged; // single piece false double piece true
Bool Color; // black false red true
CheckerPiece(BoardLocation l)
Add code here to create the piece don't make a default constructor so if the
piece is created it has to have a location 
~CheckerPiece (void)
do all your destruction code here like updating the amount of pieces left on
the board for a player 
// the guts of the game goes here
bool Move (Player p, BoardLocation l1, BoardLocation l2)
Here is where you will check to make sure the right player is picking up
this piece. I.E.   If the red player tries to get me and I am black then
throw a message if your doing an event driven program or just give an error
prompt and return if your doing it it more functional.
Then you will test and make sure what is being done with the piece is legal 
Finally you will make any changes to the board or this piece like sending a
removed message to other pieces if this is event driven or just removing
pieces if it is more functional.  Also you will update the kinged state
Then if it is event driven you will send a game winner check message here or
if functional you will just run a function to check if someone has won and
act accordingly..   
There are other functions you can add to this class but you could actually
make a checkers game out of a simple class like this.  Then later you would
just have to make another piece class like Chess to work with your board
object to make a chess game.  So you could have Othello piece class, Chess
piece class, Checkers, and what ever other games you can play on a chess
board and the pieces you instantiate would define what game is being played.

The board wouldn't even have to exist as an object it could just be
something that the pieces drew and redrew when they enter and leave the
I have seen a  card game wrote like this and all they did was have the Card
constructor draw the table for the game being played.  IN this case the
board is the same no matter if your playing chess, checkers or Othello.  So
there wouldn't have to be a switch statement for the board drawing like
there was in the card game.

From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jim
Sent: Saturday, October 13, 2007 5:22 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: game development layout question

In Object Orientation, how would I represent a checker on a square of a

Other related posts: