Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Our Scripts Vault contains many game scripts that you can use to create your own game!
Home
Forum
Help
Login
Register
BBGameZone.net
»
Webmasters
»
Coding Discussion
»
Code Help
»
2D map
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: 2D map (Read 1288 times)
Aliss
Level 9
Posts: 54
Reputation: +1/-1
2D map
«
on:
October 12, 2007, 11:48:55 AM »
I wanna ask if someone have tutorial how to make 2D maps with x and y positions width mysql suport or some simple source code. I will realy prisuited for help. because i tryd to make but widthout luck
.
«
Last Edit: October 12, 2007, 11:51:22 AM by Aliss
»
Logged
Zeggy
Global Moderator
Level 35
Posts: 1,187
Reputation: +13/-4
Re: 2D map
«
Reply #1 on:
October 13, 2007, 07:57:13 AM »
I don't have any tutorials for you, but I can help. They're farily simple:
Do you need help with the code to display a map, or the code to move a player around?
Logged
Aliss
Level 9
Posts: 54
Reputation: +1/-1
Re: 2D map
«
Reply #2 on:
October 13, 2007, 08:05:29 AM »
I need to a code to display the map.
Logged
Zeggy
Global Moderator
Level 35
Posts: 1,187
Reputation: +13/-4
Re: 2D map
«
Reply #3 on:
October 13, 2007, 08:55:30 AM »
Here's a simple code that will display a 10x10 map:
<?php
echo
"<table border=\"0\">"
;
for (
$y
=
0
;
$y
<
10
;
$y
++)
{
echo
"<tr>"
;
for (
$x
=
0
;
$x
<
10
;
$x
++)
{
if (
$player
[
'x'
] ==
$x
&&
$player
[
'y'
] ==
$y
)
{
echo
"<td><img src=\"images/player.JPG\" border=\"0\" /></td>"
;
}
else
{
echo
"<td><img src=\"images/grass.JPG\" border=\"0\" /></td>"
;
}
}
echo
"</tr>"
;
}
echo
"</table>"
;
?>
It will check the co-ordinates of the map with $player['x'] and $player['y'] which are the player's x and y positions.
Logged
Aliss
Level 9
Posts: 54
Reputation: +1/-1
Re: 2D map
«
Reply #4 on:
October 13, 2007, 09:01:16 AM »
And how about to get around a player map about to rows or one.
Logged
Zeggy
Global Moderator
Level 35
Posts: 1,187
Reputation: +13/-4
Re: 2D map
«
Reply #5 on:
October 13, 2007, 10:19:20 AM »
Look for $y<10 or $x<10 in the for loops.
The y is the number of rows, and x is the number of columns.
So if you want 2 rows, change it to $y<2, or 1 column, change to $x<1.
Logged
Aliss
Level 9
Posts: 54
Reputation: +1/-1
Re: 2D map
«
Reply #6 on:
October 13, 2007, 11:48:50 AM »
Thx for help now i have something to start
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
BBGameZone.net
»
Webmasters
»
Coding Discussion
»
Code Help
»
2D map
SimplePortal 2.3.3 © 2008-2010, SimplePortal