Reversi Tutorial

Game development with Board Game Arena Studio
Post Reply
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Reversi Tutorial

Post by tchobello »

Hi !
I'm trying to create a reversi clone thanks to the tutorial http://en.doc.boardgamearena.com/Tutorial_reversi and I 've already met a problem at the very beginning.

I'm unable to have all 64 red squares.
There's only the last one bottom right
It seems "$this->page->insert_block( "square", array(..." only works once at the end of the two loops when $x & $y are 8.

when I look at the source code, I only have
<div id="board">
<!-- BEGIN square -->
<div id="square_8_8" class="square" style="left: 464px; top: 458px;"></div>
<!-- END square -->
</div>


I suppose i should have 64 occurences.

Can someone help me ? Thanks a lot
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Reversi Tutorial

Post by fafa-fr »

Hi,
No, the problem is not that there is only 1 occurrence in your block definition in .tpl file (this is normal), the problem is you should have variables, not real values (eg. id="square_{X}_{Y}" and not id="square_8_8", and also for top and left values). You can read the complete explanation in the reversi tutorial, part "Make the squares appear".
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Reversi Tutorial

Post by tchobello »

fafa-fr wrote:Hi,
No, the problem is not that there is only 1 occurrence in your block definition in .tpl file (this is normal), the problem is you should have variables, not real values (eg. id="square_{X}_{Y}" and not id="square_8_8", and also for top and left values). You can read the complete explanation in the reversi tutorial, part "Make the squares appear".
thanks for answering.

in the .tpl file there is :
<div id="board">
<div id="square_{X}_{Y}" class="square" style="left: {LEFT}px; top: {TOP}px;"></div>
</div>


<div id="square_8_8" class="square" style="left: 464px; top: 458px;"></div> appears in the source code for the client side.
I did not write that in the *.tpl neither calculate 464 and 458.
User avatar
fafa-fr
Posts: 383
Joined: 22 December 2013, 21:58

Re: Reversi Tutorial

Post by fafa-fr »

Oh sorry, I didn't understand you were speaking about the html source on your browser.
Can you post your whole square block loop? (from this->page->begin_block...)
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Reversi Tutorial

Post by tchobello »

fafa-fr wrote:Oh sorry, I didn't understand you were speaking about the html source on your browser.
Can you post your whole square block loop? (from this->page->begin_block...)
no problem !

$this->page->begin_block( "reversi_reversi", "square" );

$hor_scale = 64.8;
$ver_scale = 64.4;
for( $x=1; $x<=8; $x++ ) {
for( $y=1; $y<=8; $y++ ) {
$this->page->insert_block( "square", array(
'X' => $x,
'Y' => $y,
'LEFT' => round( ($x-1)*$hor_scale+10 ),
'TOP' => round( ($y-1)*$ver_scale+7 )
) );
}
}


the game is huntreversi if you have access to it.
I just did some copy/paste.
The loop seems to be OK as i was able to print all left and top values but impossible to have 64 red squares, only the last one.
User avatar
DrKarotte
Posts: 279
Joined: 22 September 2015, 23:42

Re: Reversi Tutorial

Post by DrKarotte »

I cannot see this strange line of code neither in the "official" reversi code nor in your version. From where did you get this code you work with? Maybe some of the numerous "reversi tests" on the studio?

I cannot start "huntreversi", there is an error message (reason: a line defining "gameinfos" is commented out).
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Reversi Tutorial

Post by tchobello »

DrKarotte wrote:I cannot see this strange line of code neither in the "official" reversi code nor in your version. From where did you get this code you work with? Maybe some of the numerous "reversi tests" on the studio?

I cannot start "huntreversi", there is an error message (reason: a line defining "gameinfos" is commented out).
just a copy/paste from here :
http://en.doc.boardgamearena.com/Tutorial_reversi

sorry for huntreversi, i forgot to delete some further code i've added for the tokens !
User avatar
Victoria_La
Posts: 620
Joined: 28 December 2015, 20:55

Re: Reversi Tutorial

Post by Victoria_La »

You have to change template name, instead of
$this->page->begin_block( "reversi_reversi", "square" );
it should be
$this->page->begin_block( "huntreversi_huntreversi", "square" );

because its called huntreversi_huntreversi.tpl
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Reversi Tutorial

Post by tchobello »

Victoria_La wrote:You have to change template name, instead of
$this->page->begin_block( "reversi_reversi", "square" );
it should be
$this->page->begin_block( "huntreversi_huntreversi", "square" );

because its called huntreversi_huntreversi.tpl
thanks a lot !
it takes some time for me to get used to BGA Framework.
User avatar
tchobello
Posts: 526
Joined: 18 March 2012, 13:19

Re: Reversi Tutorial

Post by tchobello »

hello...

yet another problem...

all tokens are white !

the 'board' table is ok with both board_player values (2307567 and 2307568) at right places.
I don't understand why it's ff0000 and 008000 in player's color in 'player' table because default colors are ffffff and 000000 in setupNewGame in game.php.


Even when I only use addTokenOnboard, I always have white tokens.

edit : I forgot to delete the favorite color selection...
Post Reply

Return to “Developers”