board rotation, player perspective
Posted: 29 May 2013, 16:56
Have a general development question for any developers who have had to implement player-perspective dependent views of the board. I'm working on the game 'Isaac' which has a white and black player facing each other placing/removing pieces on the board. Originally the board was developed only with the 'white' player perspective and placement 'squares' on the board.
I was able to rotate the board display for the color black player using the rotate command similar to the way I was rotating the pieces via javascript. The problem I'm running into now is for the black player(180 degree rotated board), when I choose or place a piece it tries to place the piece down-page of the play area, successively lower if I change pieces and further test placement. If any developer wishes to see this error in action, I'm going to leave my code un-modified for a week from the time of this post(so after that, things will be different as I work towards some type of solution)
Below is my .tpl code, if I move the div for tokens to outside/above the board div, it seems like it works partly correctly in that it doesn't try to place below the board area, but test and chosen pieces are covered by the board.
The solution which has been offered so far is to rotate the board image only and use the view.php to generate a separate placement grid/view for the opposite/black player, and this is what I'll go with if no one else has a better solution they are using or more info to troubleshoot with. I was hoping that I might be able to get by with just rotating the board(which included the placement squares within its div) without adding more to view.php, but I can't figure out what is going on with the issue mentioned above.
Thanks
Jeremy
I was able to rotate the board display for the color black player using the rotate command similar to the way I was rotating the pieces via javascript. The problem I'm running into now is for the black player(180 degree rotated board), when I choose or place a piece it tries to place the piece down-page of the play area, successively lower if I change pieces and further test placement. If any developer wishes to see this error in action, I'm going to leave my code un-modified for a week from the time of this post(so after that, things will be different as I work towards some type of solution)
Below is my .tpl code, if I move the div for tokens to outside/above the board div, it seems like it works partly correctly in that it doesn't try to place below the board area, but test and chosen pieces are covered by the board.
The solution which has been offered so far is to rotate the board image only and use the view.php to generate a separate placement grid/view for the opposite/black player, and this is what I'll go with if no one else has a better solution they are using or more info to troubleshoot with. I was hoping that I might be able to get by with just rotating the board(which included the placement squares within its div) without adding more to view.php, but I can't figure out what is going on with the issue mentioned above.
Thanks
Jeremy
Code: Select all
<script type="text/javascript">
// Templates
var jstpl_token='<div class="token tokencolor_${color}_${piecetype}" id="token_${x_y}"></div>';
var jstpl_token_test='<div class="token_test tokencolor_${color}_${piecetype}" id="token_test"></div>';
var jstpl_piece='<div class="piece piececolor_${color}_${piecetype}" id="piecetype_${piecetype}"></div>';
var jstpl_score='<div class="scoreMarker scorecolor_${color}" id="score_marker_${player_id}"></div>';
</script>
<div id="board">
<div id="tokens">
</div>
<div id="scores">
</div>
<!-- BEGIN square -->
<div id="square_{X}_{Y}" class="square" style="left: {LEFT}px; top: {TOP}px;"></div>
<!-- END square -->
</div>
<div id="area_pieces">
<!-- BEGIN square_piece -->
<div id="square_piece_{X}_{Y}" class="square_piece" style="left: {LEFT}px; top: {TOP}px;"></div>
<!-- END square_piece -->
<div id="pieces">
</div>
</div>