Hi,
I'm a new developer and I'm trying to learn how to develop games on Board Game Arena Studio. For that and to get a grasp on how the framework works I'm currently following the Reversi tutorial.
I'm currently trying to create the grid using the insert_block function. I've copy-pasted the code from the tutorial:
HTML in .tpl file:
PHP:
And the result is this visually:
Only the bottom red block appears as a red square, even though from the tutorial I should have expected a grid full of red squares. You can see using my browser's developer tools:
I do not understand why that is the case. It seems like every time the insert_block functions is called it overrides the last inserted block instead of adding it. So I add the following lines of code after the unedited PHP code from the tutorial:
It gave the following result:
The bottom right square is replaced by a top left square which is exactly as expected.
How to make sure that the function insert_block adds a block instead Is the tutorial out of date? Or did I miss something obvious to make sure that blocks are added instead of overwritten?
Worst case scenario as a workaround I define all blocks in the .tpl file but I'd like to avoid that especially if at some point I ever have to make a game with dynamic and variable block insertion.
Thanks for your help!
I'm a new developer and I'm trying to learn how to develop games on Board Game Arena Studio. For that and to get a grasp on how the framework works I'm currently following the Reversi tutorial.
I'm currently trying to create the grid using the insert_block function. I've copy-pasted the code from the tutorial:
HTML in .tpl file:
Code: Select all
<div id="board">
<!-- BEGIN square -->
<div id="square_{X}_{Y}" class="square" style="left: {LEFT}px; top: {TOP}px;"></div>
<!-- END square -->
</div>
Code: Select all
$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 )
) );
}
}
Only the bottom red block appears as a red square, even though from the tutorial I should have expected a grid full of red squares. You can see using my browser's developer tools:
I do not understand why that is the case. It seems like every time the insert_block functions is called it overrides the last inserted block instead of adding it. So I add the following lines of code after the unedited PHP code from the tutorial:
Code: Select all
$this->page->insert_block( "square", array(
'X' => 1,
'Y' => 1,
'LEFT' => 10,
'TOP' => 70
) );
The bottom right square is replaced by a top left square which is exactly as expected.
How to make sure that the function insert_block adds a block instead Is the tutorial out of date? Or did I miss something obvious to make sure that blocks are added instead of overwritten?
Worst case scenario as a workaround I define all blocks in the .tpl file but I'd like to avoid that especially if at some point I ever have to make a game with dynamic and variable block insertion.
Thanks for your help!