Page 1 of 1

[php] printing a chessboard-like dungeon.

Posted: Sun Oct 03, 2010 2:09 pm
by Age of Fable
I've just started working on a game similar to ChessRogue.

Both ChessRogue and my game take place in a dungeon whose inhabitants' movements are like those of chess pieces.

At http://www.apolitical.info/private/rogue/levelgen , I've got some code which creates a dungeon level, and prints it. EDIT I've changed the code so it prints plain text rather than a table with background colors.

However this appears to be very slow compared to printing plain text. This is a problem because I want the game to be browser-based. However the chessboard setup should be helpful for telling (eg) if two creatures are on the same diagonal.

Is there a faster way to get the same effect I've got here?

Re: [php] printing a chessboard-like dungeon.

Posted: Sun Oct 03, 2010 2:32 pm
by hallsofvallhalla
yes, first off you are using tables..that is tooo many.

Look at my javascript/ajax tutorials. I have a way of build 100's of divs very fast and it assigns each div a tag. For mine they are 30 across.
So I know
to the left of current div is -1
to the right is +1
up on is -30
down one is +30

so if I want to check to see if the diagonal div up and to the left of my player i do a simple

Code: Select all

$checkdiv = playerdiv - 31;
if($checkdiv = $monster)
{
do this!
}

http://indie-resource.com/forums/viewto ... =26&t=2283

Re: [php] printing a chessboard-like dungeon.

Posted: Sun Oct 03, 2010 10:24 pm
by Age of Fable
Which one/s do I need to look at?

Re: [php] printing a chessboard-like dungeon.

Posted: Mon Oct 04, 2010 12:51 am
by hallsofvallhalla