Danny620 Posted June 4, 2012 Share Posted June 4, 2012 I am in need of a PHP & Ajax game map like tribal wars. I know that this is very possible with Flash and Java, but am not looking to use either of those. - Only show 10x10 of the game map at a time along with arrows to scroll left, right, up, down. - When a user registers or doesn't have any map coordinates, we need to store a random x and y coordinate in the database per player that hasn't already been used. - Map needs to display player location based on their x&y coordinates. Where a user doesn't exist, terrain needs to be generated. What would be the best way to go out this anyone got any tuts Quote Link to comment Share on other sites More sharing options...
Psycho Posted June 4, 2012 Share Posted June 4, 2012 What would be the best way to go out this . . . Lay out what features you want to create in order of importance then attack one thing at a time. You should remove AJAX from the equation for now since most of what you will need to develop wouldn't require it. I would start by create a process/function to create the map based up coordinates given. Just create a page where you can enter the coordinates and click a button to generate the map - or put the coordinates into the query string. Then determine how you want the navigation to work. If the coordinates are sent through POST values then each array will need to be a form input control and you will need hidden field to provide the current position and the direction change or just the new coordinates you want. If the coordinates are sent through the query string then you just need the nav controls to be links to get the new map. Once all that is working, THEN implement AJAX to call the new map without a page load. Quote Link to comment Share on other sites More sharing options...
Danny620 Posted June 4, 2012 Author Share Posted June 4, 2012 ive built this so far http://www.northplanet.co.uk/Game/map.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> .grass { float: left; height: 40px; width: 40px; background-image: url(images/images.png); border: 1px solid #007500; color: #FFF; font-size: 15px; font-weight: bold; text-align: center; vertical-align: middle; line-height: 40px; } .separator { clear: left; float: left; width: 252px; height: 40px; } </style> </head> <body> <?php $map_size = 54; $tiles_per_line = 6; $count = 1; $tile_id = 1; $x = 0; $y = 0; while($i<=$map_size){ if($count <= $tiles_per_line){ $grass = 1; echo '<div class="separator">'; while($grass <= $tiles_per_line){ echo '<div class="grass">'.$tile_id.'</div>'; $grass ++; $tile_id ++; } echo '</div>'; $count++; } $i++; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Danny620 Posted June 5, 2012 Author Share Posted June 5, 2012 Ok so far ive been able to draw a map on screen and plot villages a and trees how would i be able to grow the map but just show some of it like i have now i.e have arrows at side of map to move to diffrent plot of land on bigger map? heres my code so far <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Game Idea</title> <style type="text/css"> .grass { float: left; height: 40px; width: 40px; background-image: url(images/images.png); } .separator a { float: left; height: 40px; width: 40px; display: block; } .village { float: left; height: 40px; width: 40px; background-image: url(images/village.png); } .water { float: left; height: 40px; width: 40px; background-image: url(images/water.png); } .tree { float: left; height: 40px; width: 40px; background-image: url(images/tree.png); } .separator { clear: left; float: left; width: auto; height: 40px; } </style> </head> <body> <?php $map_size = 108; $tiles_per_line = 12; $count = 1; $tile_id = 0; $x = 0; $y = 0; $plot = array( 47 => 'w', 54 => 'w', 85 => 'w', 74 => 'w', 87 => 't', 143 => 't', 2 => 't', 34 => 't', 12 => 'v', 14 => 'v', 22 => 'v', 32 => 'v', 114 => 'v', 140 => 'v' ); while ($i <= $map_size) { if ($count <= $tiles_per_line) { $grass = 1; echo '<div class="separator">'; while ($grass <= $tiles_per_line) { if (isset($plot[$tile_id])) { switch ($plot[$tile_id]) { case "v": echo '<div class="village"><a href="view.php?village=' . $tile_id . '"></a></div>'; break; case "t": echo '<div class="tree"></div>'; break; case "w": echo '<div class="water"></div>'; break; } } else { echo '<div class="grass"></div>'; } $grass++; $tile_id++; } echo '</div>'; $count++; } $i++; } ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
Danny620 Posted June 5, 2012 Author Share Posted June 5, 2012 http://www.northplanet.co.uk/Game/map.php Quote Link to comment Share on other sites More sharing options...
Danny620 Posted June 5, 2012 Author Share Posted June 5, 2012 any help? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.