Porl123 Posted September 29, 2008 Share Posted September 29, 2008 I'm trying to make a little game, which I guess I'll be using PHP/MySQL to make. I know you guys are busy so I'll try and make this as brief and as detailed at the same time as I possibly can :X I'm trying to make a game based around coordinates. Ideally I'm trying to make it so there's a grid playing field, that would be -99 to 99 both horizontally and vertically, although it only displays the grid 9 by 9 with your character center and middle of the table. I'd need a for() loop to make the 9 by 9 grid and I can position the character, although I'm not sure how you would manage the links. (<a href="?x=$x&y=$y"><img src="square.gif" /></a>) If you have any hints or clues you can give me, or if possible any tutorials based around this area I'd be very appreciative thanks people. I wouldn't normally ask for something this broad on here but I've been trying to make this for a while and just need a bump to show I've been going at it the right way Quote Link to comment Share on other sites More sharing options...
btherl Posted September 29, 2008 Share Posted September 29, 2008 I'm not entirely sure what your question is here Have you decided how you will store the playing field? A 2 level array? Quote Link to comment Share on other sites More sharing options...
Porl123 Posted September 29, 2008 Author Share Posted September 29, 2008 I was planning to have it so each character has an x and a y field in the users table, which updates the coordinates to the new ones every time they move, but yeah it'd be 2 level unless someone tells me to do otherwise =p Quote Link to comment Share on other sites More sharing options...
Porl123 Posted September 29, 2008 Author Share Posted September 29, 2008 If there's anymore info you want to know please ask really want to get started with this Quote Link to comment Share on other sites More sharing options...
btherl Posted September 30, 2008 Share Posted September 30, 2008 Hmm.. do you have any code yet? Having something to work with makes it much easier. And the question of how to show the links depends on your data structure. So let's say you're using a 2 level array like this: ini_set('memory_limit', '64M'); function blank_map() { $map = array(); for ($y = -10; $y <= 10; $y++) { $row = array(); for ($x = -10; $x <= 10; $x++) { $row[$x] = array( 'terrain' => rand(0,1) ? 'grass' : 'sand', 'objects' => array(), ); } $map[$y] = $row; } return $map; } function display_map($map) { foreach ($map as $y) { foreach ($y as $x) { if ($x['terrain'] == 'grass') { print "\""; } elseif ($x['terrain'] == 'sand') { print "-"; } } print "\n"; } } $map = blank_map(); display_map($map); I'm limiting it to -10 to 10 for debugging. For -99 to 99 you will probably need to increase the memory limit. Is that the kind of thing you're looking for? 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.