First of all, I should point out that I’m new to php. But, I’m trying my best to learn it. The only way I can learn something is by doing it, so I gotta work via useful example. :S
That said, I’m working on modifying a php script for a game. In the game, I’m wanting to set a condition where a character is not allowed to move to a specfic adjacent space. With what little I’ve learned in Visual BASIC, I’m thinking this involves some sort of php versioned if statement. But I’m not sure how to set it up.
Here’s the code that controls character.
[code=php]
$latitude = $userrow[“latitude”];
$longitude = $userrow[“longitude”];
if (isset($_POST[“north”])) { $latitude++; if ($latitude > $controlrow[“gamesize”]) { $latitude = $controlrow[“gamesize”]; } }
if (isset($_POST[“south”])) { $latitude–; if ($latitude < ($controlrow[“gamesize”]*-1)) { $latitude = ($controlrow[“gamesize”]*-1); } }
if (isset($_POST[“east”])) { $longitude++; if ($longitude > $controlrow[“gamesize”]) { $longitude = $controlrow[“gamesize”]; } }
if (isset($_POST[“west”])) { $longitude–; if ($longitude < ($controlrow[“gamesize”]*-1)) { $longitude = ($controlrow[“gamesize”]*-1); } }
Say there’s an uncrossable mountain range in an area.. or the user comes to an ocean or lake shore? How do I tell it not to let the character move there. I should probably have it display a special “Character can’t go any further this way.” message when the user encounters such instances too.
Is there a patient person out there who can teach me how to do this one?