Kryllster Posted August 24, 2009 Share Posted August 24, 2009 Some may know Im trying to write a game in php but here again Im working on an interactive script trying to use if statements and such because I'm not sure where to go from here. Here is some sample code from where I'm at with it. <?php $fight = (!isset($_GET['fight'])) ? 'main' : $_GET['fight']; switch($fight){ case 'fight1': $fight = $_POST['fight']; $first = mt_rand(1,100); if($first <= 60){ $first = "The Cultist Guard"; } if($first > 60){ $first = "You"; } $hitpoints = 30; $monster_hp = 30; if (isset($_POST['fight'])) { header("Location:fight_view.php?fight=fight1&first=$first&hitpoints=$hitpoints&monster_hp=$monster_hp"); } break; } ?> <html> <head> <title>Crimson Diamond</title> <link rel="stylesheet" type="text/css" href="default.css" media="screen"> <SCRIPT TYPE="text/javascript"> function popup(mylink, windowname) { if (! window.focus)return true; var href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; window.open(href, windowname, 'width=500,height=300,scrollbars=yes'); return false; } </SCRIPT> <body> <center><h2>Fight the Cultist Guard !!</h2></center> <center> <table width="400"> <tr> <td> <center>Who Attacks First:<?php echo $first; ?></center> </tr> </table> <table width="400"> <tr> <td> <center>Your Hitpoints:<?php echo $hitpoints; ?></center> </td> <td> <center>Monster Hitpoints:<?php echo $monster_hp; ?></center> </td> </tr> </table> </center> <hr> <center> <form action="fight_view.php?fight=fight1" method="post"> <input type="submit" name="fight" value="Attack With Your Weapon"> </form> <br> <p><b>Select A Skill</b></p> <select> <option value="">Skill 1</option> <option value="">Skill 2</option> <option value="">Skill 3</option> </select> <br> </center> </body> </html> Any pointers I can do to advance my php coding would be helpful not wanting to actually have someone do it for me just to point me where to go to learn. I don't want to be a copy and paste guy any longer. Link to comment https://forums.phpfreaks.com/topic/171571-new-question-old-topic/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.