Porl123 Posted September 3, 2008 Share Posted September 3, 2008 I've created a topic before about making this game in php and mysql, which would be on a -250x250 grid but would only display 11x11, displaying your character in the center/middle of the table and being able to click the surrounding squares to change coordinates. I thought I'd realized how to make one of these map explore games but I've really got no ideas for some bits, so if anyone has any general hints or any tutorials for learning how to make something like this it would be greatly appreciated. Thanks in advance people Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/ Share on other sites More sharing options...
pocobueno1388 Posted September 3, 2008 Share Posted September 3, 2008 You need to create an image map. Here is a tutorial http://www.htmlcodetutorial.com/images/images_famsupp_220.html Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-632398 Share on other sites More sharing options...
Porl123 Posted September 3, 2008 Author Share Posted September 3, 2008 I meant more something in php/mysql, for example the way you'd move would be like <a href="?action=move&x=$x&y=$y"><img src="square.gif"></a> If that makes any sense :x I mean like a map grid that you can travel around Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-632400 Share on other sites More sharing options...
Porl123 Posted September 3, 2008 Author Share Posted September 3, 2008 I wouldn't normally ask something this broad on here but I've been trying to figure this out for a few weeks and can't figure how it works Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-632402 Share on other sites More sharing options...
Porl123 Posted September 3, 2008 Author Share Posted September 3, 2008 Nobody have any ideas? :x Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-632412 Share on other sites More sharing options...
Porl123 Posted September 3, 2008 Author Share Posted September 3, 2008 I can post examples of other sites which use similar systems if anyone's interested? Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-632425 Share on other sites More sharing options...
l0gic Posted February 27, 2012 Share Posted February 27, 2012 I know this is a bit of a thread necro, but I saw this while looking for something else and thought it couldn't be too hard to work with. Anyway, I came up with this: <?php $horitiles = 5; // how many tiles wide $verttiles = 5; // how many tiles high $v = 0; $h = 0; $maxmovesize = 1; // hos many tiles can you move per-move (not perfect though, change it to 2 or 3 and see) // there is treasure in the map for you to find, you can find it easy by looking at the querystring // if theres no querystring setting treasure it'll be at tile 2,2 if(isset($_REQUEST['th']) && isset($_REQUEST['tv'])) { $treasureh = $_REQUEST['th']; $treasurev = $_REQUEST['tv']; }else { $treasureh = 2; $treasurev = 2; } // current position, default if nothing in querystring is 1,1 if(isset($_REQUEST['v'])) { $currentv = $_REQUEST['v']; }else { $currentv = 1; } if(isset($_REQUEST['h'])) { $currenth = $_REQUEST['h']; }else { $currenth = 1; } echo "<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\">"; while($v < $verttiles) { echo "<tr>"; while($h< $horitiles) { if($v == $currentv && $h == $currenth) { if($h == $treasureh && $v ==$treasurev) { echo "<td><img src=\"tile-treasure.jpg\"></td>"; $treasure = "You found the treasure!<br>"; $treasureh = rand(1,$horitiles)-1; $treasurev = rand(1,$verttiles)-1; $link="<a href=\"map.php?h=$h&v=$v&th=$treasureh&tv=$treasurev\">Reset!</a>"; }else { echo "<td><img src=\"tile-on.jpg\"></td>"; $treasure = ""; $link=""; } }else { $gol = $currenth-$maxmovesize; $gor = $currenth+$maxmovesize; $gou = $currentv-$maxmovesize; $god = $currentv+$maxmovesize; if($h >= $gol && $h <= $gol+$maxmovesize && $v == $currentv || $h >= $gol && $h <= $gol+$maxmovesize && $v == $currentv+1 || $h >= $gol && $h <= $gol+$maxmovesize && $v == $currentv-1 || $h <= $gor && $h >= $gol+$maxmovesize && $v == $currentv || $h <= $gor && $h >= $gor-$maxmovesize && $v == $currentv+1 || $h <= $gor && $h >= $gor-$maxmovesize && $v == $currentv-1) { echo "<td><a href=\"map.php?h=$h&v=$v&th=$treasureh&tv=$treasurev\"><img src=\"tile-move.jpg\" border=\"0\"></a></td>"; }else if($v >= $gou && $v <= $gou+$maxmovesize && $h == $currenth || $v >= $gou && $v <= $gou+$maxmovesize && $h == $currenth+1 || $v >= $gou && $v <= $gou+$maxmovesize && $h == $currenth-1 || $v <= $god && $v >= $god-$maxmovesize && $h == $currenth || $v <= $god && $v >= $god-$maxmovesize && $h == $currenth+1 || $v <= $god && $v >= $god-$maxmovesize && $h == $currenth-1) { echo "<td><a href=\"map.php?h=$h&v=$v&th=$treasureh&tv=$treasurev\"><img src=\"tile-move.jpg\" border=\"0\"></a></td>"; }else { echo "<td><img src=\"tile.jpg\"></td>"; } } $h++; } $h = 0; echo "</tr>"; $v++; } echo "</table>"; echo "<br>"; echo $treasure."<br>"; echo $link; ?> I've attached the images I've used as tiles 32x32 icon size. This is a very simple take on it and some code is redundent, would've used a database but didn't have access to one on the machine I was using. Though it could easily be converted to use a database (and even have multiplayer support over a larger 'map'). Something fun to play with, was a lot of fun to make as I've been out of PHP for about 12 months and am starting my return at the moment! Could be done a lot better, but hey, it's an idea. Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-1321801 Share on other sites More sharing options...
Zane Posted February 27, 2012 Share Posted February 27, 2012 Wow, 4 years ago!? Really? Even though the information you provided is very detailed and downright relevant to the OP, you shouldn't necro. I see your intentions are good, but 4 years?? Well, 3 years and some change. Anyway. I'm locking this. Link to comment https://forums.phpfreaks.com/topic/122474-map-coordinates/#findComment-1321805 Share on other sites More sharing options...
Recommended Posts