Jump to content

Waffles007

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

About Waffles007

  • Birthday 02/10/1986

Profile Information

  • Gender
    Male
  • Location
    Somewhere

Waffles007's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I see. Thank you very much for that insight. I was able to get my code working properly now. I also needed to change the increment type from ++ to += # which helped immensely with the speed. Thanks HuggieBear. Wow, that's pretty cool, taquitosensei. However I have never used switches before so that looks strange to me. I'll do some reading on switches. Thanks for that. Final Code: $latitude = $userrow["latitude"]; $longitude = $userrow["longitude"]; if (isset($_POST["post"])) { if (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move0"))) {$latitude += 1; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move1"))) {$latitude += 2; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move2"))) {$latitude += 3; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move3"))) {$latitude += 4; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move4"))) {$latitude += 5; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north") && (isset($_POST["speed"]) && ($_POST["speed"] == "move5"))) {$latitude += 6; if ($latitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move0"))) {$latitude -= 1; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move1"))) {$latitude -= 2; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move2"))) {$latitude -= 3; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move3"))) {$latitude -= 4; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move4"))) {$latitude -= 5; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "south") && (isset($_POST["speed"]) && ($_POST["speed"] == "move5"))) {$latitude -= 6; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move0"))) {$longitude += 1; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move1"))) {$longitude += 2; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move2"))) {$longitude += 3; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move3"))) {$longitude += 4; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move4"))) {$longitude += 5; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "east") && (isset($_POST["speed"]) && ($_POST["speed"] == "move5"))) {$longitude += 6; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move0"))) {$longitude -= 1; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move1"))) {$longitude -= 2; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move2"))) {$longitude -= 3; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move3"))) {$longitude -= 4; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move4"))) {$longitude -= 5; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "west") && (isset($_POST["speed"]) && ($_POST["speed"] == "move5"))) {$longitude -= 6; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } } Thanks again for the help. Waffles
  2. I'm sorry I don't follow. What do you mean by more specific rules?
  3. Thank you Huggiebear, that's cleared up some confusion. With your input My code turns into this: if (isset($_POST["direction"]) && ($_POST["direction"] == "north")) {$latitude++; if ($longitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif (isset($_POST["direction"]) && ($_POST["direction"] == "north")) && (isset($_POST["speed"]) && ($_POST["speed"] == "move1")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } Is that second statement correct? Is doing that possible? Essentially I'm trying to tell the script if two selections are true do this. Thanks again.
  4. Hello everyone, I'm simply trying to move a character on a map. When the user selects a direction and a speed the character is moved on the map. Simple right? I've tried a few methods of doing this to no avail. I will list the different things I've tried. <form action="index.php?do=move" method="post"> <select name="direction"> <option value="north" selected>North</option> <option value="south">South</option> <option value="east">East</option> <option value="west">West</option> </select> <select name="speed"> <option value="move0" selected>Feet +0</option> <option value="move1">Goat +1</option> <option value="move2">Donkey +2</option> <option value="move3">Cow +3</option> <option value="move4">Pig +4</option> <option value="move5">Horse +5</option> </select><br /> <input type="submit" name="post" value="Move"> </form> if (isset($_POST["post"])) { if (isset($_POST["direction"]) == "north") {$latitude++; if ($longitude > $controlrow["gamesize"]) { $latitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move1")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move2")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move3")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move4")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "north") AND (($_POST["speed"]) == "move5")) {$latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "south") {$latitude--; if ($latitude < ($controlrow["gamesize"]*-1)) { $latitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move1")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-2)) { $latitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move2")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-3)) { $latitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move3")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-4)) { $latitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move4")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-5)) { $latitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "south") AND (($_POST["speed"]) == "move5")) {$latitude--; if ($latitude < ($controlrow["gamesize"]*-6)) { $latitude = ($controlrow["gamesize"]*-6); } } elseif (isset($_POST["direction"]) == "east") {$longitude++; if ($longitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move1")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*2)) { $longitude = ($controlrow["gamesize"]*2); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move2")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*3)) { $longitude = ($controlrow["gamesize"]*3); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move3")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*4)) { $longitude = ($controlrow["gamesize"]*4); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move4")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*5)) { $longitude = ($controlrow["gamesize"]*5); } } elseif ((isset($_POST["direction"]) == "east") AND (($_POST["speed"]) == "move5")) {$longitude++; if ($longitude > ($controlrow["gamesize"]*6)) { $longitude = ($controlrow["gamesize"]*6); } } elseif (isset($_POST["direction"]) == "west") {$longitude--; if ($longitude < ($controlrow["gamesize"]*-1)) { $longitude = ($controlrow["gamesize"]*-1); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move1")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-2)) { $longitude = ($controlrow["gamesize"]*-2); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move2")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-3)) { $longitude = ($controlrow["gamesize"]*-3); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move3")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-4)) { $longitude = ($controlrow["gamesize"]*-4); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move4")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-5)) { $longitude = ($controlrow["gamesize"]*-5); } } elseif ((isset($_POST["direction"]) == "west") AND (($_POST["speed"]) == "move5")) {$longitude--; if ($longitude < ($controlrow["gamesize"]*-6)) { $longitude = ($controlrow["gamesize"]*-6); } } } Also if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move0")) { $latitude++; if ($latitude > $controlrow["gamesize"]) { $longitude = $controlrow["gamesize"]; } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move1")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*2)) { $latitude = ($controlrow["gamesize"]*2); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move2")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*3)) { $latitude = ($controlrow["gamesize"]*3); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move3")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*4)) { $latitude = ($controlrow["gamesize"]*4); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move4")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*5)) { $latitude = ($controlrow["gamesize"]*5); } } else { if ((isset($_POST["post"]) == "north") && (isset($_POST["speed"]) == "move5")) { $latitude++; if ($latitude > ($controlrow["gamesize"]*6)) { $latitude = ($controlrow["gamesize"]*6); } } } } } } } Any help would be appreciated. If you need more info just ask. Thanks, Waffles
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.