Game Development Community

Checker demo

by Harrison Brock · in Torque Game Builder · 11/14/2006 (9:57 pm) · 1 replies

Am try to re-make the checker so that is one player and one AI player. I have load the checker board and made the tile map ( the logic checker board) just like the checkerdemo that came with TGB. But am have a hard time get the checker pices to load from scripts.

I use this to check for the place to the checker:

function CheckerBoard::isBlack(%this, %x, %y)
{
// this will decide if a checkerboard slot is black
if( (%x % 2) && (%y % 2) )
return true;
else if( %x % 2 || %y % 2 )
return false;
else
return true;
}

this to set the checker

function CheckerBoard::setPiece(%this, %x, %y, %type)
{
// set the board's array position
%this.board[%x,%y] = %type;
}

and

function CheckerBoard::init(%this)
{
// init the team counts
$redCount = 0;
$blueCount = 0;

// loop through and create the server board
for(%x = 0; %x < 8;%x++)
{
for(%y = 0;%y < 8;%y++)
{
// check if this is a black checkerboard spot
if(%this.isBlack( %x, %y ))
{
// check if this is a checker's starting spot
if(%y < 2)
{
// set the the red team's piece and add to the count
%this.setPiece(%x, %y, $red);
$redCount++;
} else if( %y > 5 )
{
// set the the blue team's piece and add to the count
%this.setPiece(%x, %y, $blue);
$blueCount++;
} else
{
// set the blank spot
%this.setPiece(%x, %y, $none);
}
}
else
{
// set the blank spot
%this.setPiece(%x, %y, $none);
}
}
}
}

but no checker load. Is there an easier way to do this? Could some one point me in the right way?

#1
02/20/2007 (3:39 am)
Ive also problems with the Server Gui. It doesnt disappear as mentioned in the tutorial. And the pieces do not appear. Ive gone thru the scripts, but did not find the error. Ive detected one error which comes up the first time I wanted to check the connection between client and server. Its in line 105 of checkerboard.cs:
the variable midspot has no % at the beginning!! in teh tutorial script. But when I fixed this, there is also no disappaering of the Server-Connection GUI and also no appaering of the red and blue pieces.
Any comments or help?