Hello-
I'm doing a little playing around with integrating FLASH and PHP.
I'm trying to create a simple game that displays a grid map, and an icon for the current players location. So far this works fine, and the user can press directional keys on a compass to move around.
The user's X,Y coordinates are stored in a mysql database and retrieved with PHP and then loaded into flash.
Now for the part I need help with.
I'd like to show Icons for other player's locations if they are located within a given distance from the current player. Kind of like a radar showing blips for targets within range. So, my question really has two parts:
1) How can I select the users from the database if they are within a given range of the current users coordinates. The problem is, if you move off the map on one side, you appear on the other. So, I can't just use a simple subtractions function. For example, if the grid ranges from 0-10 in X and Y, and the user is at 2 on the X axis, and I want to find all targers within 3 units, it would need to search from 10, 1, 2 and 3, 4, 5 on the X axis. So... any ideas on how to do this? Seems like an array would do the trick, but I'm not sure on the specifics of implementation.
2) This is a FLASH ACTIONSCRIPT question, but nobody on Macromedia's forum responded. Once I've selected the user locations and return them to FLASH, how to I dynamically generate instances of the icon object based on the number of players detected? This would constantly change as the current player moved around. I'd like to show player locations within a given radius of the current player's present location. If a unit is out of range on the next move, that icon should be removed from the map.
Hope this all makes sense.
Thanks,
Sledge