hello all,
For a school assignment, I'm creating a text-based haunted house game in PHP. I have the assignment mostly complete, except that the user has to be able to progress to another room if not attacked by a monster. My teacher e-mailed me this:
The refresh part lets me check for randomness.
The 'progress to another room' begins the necessity of storing the user's changing location, lives left, level of difficulty, location of exits, etc. as the user leaves a room.
Even though the user leaves the room, you, the programmer, will continue to use the game board that you have already made. All you will be doing is monitoring by which door the user leaves and keeping track of the 'winning' door.
The problem can be solved in many ways, one of which is using parallel arrays that keep track of doors in arrRoomFileNames[ ].
I hope this helps.
The code is here:
<!-- Gameboard -->
<html>
<head>
<title>Layout for gameboard</TITLE>
<style>
body {background: #222244;
}
table {width: 800px;
height: 500px;
margin: 0px;
padding: 0px;
border: none;
}
</style>
</head>
<body>
<center>
<?php
$arrRoomFileNames=array("bathroom.JPG", "office.JPG", "cbed.JPG", "study.JPG", "kitchen.JPG", "sroom.JPG" , "foyer.JPG", "mbed.JPG", "froom.JPG");
$chosenroom=$arrRoomFileNames[rand(0,8)];
?>
<table>
<tr height="450px">
<td width="650px" background="echo '<img src='.$arrRoomFileNames[$chosenroom].'>; ?>">Playing board</td>
<td bgcolor=#cfc9a9></td>
</tr>
<tr>
<td bgcolor=#dfd9b9 colspan=2>Lives remaining: 3</td>
</tr>
</table>
</center>
</body>
</html>
Thank you.