Question about parallel arrays (PHP)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ygugsa295
    FFR Player
    • Oct 2006
    • 155

    #1

    Question about parallel arrays (PHP)

    I'm creating a haunted house text-based game in PHP for a school assignment. I have most of the stuff down, except that there has to be a way for the user to progress to another room. From my e-mail:

    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.
    Code:
    <!-- 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>
    Can someone explain to me how parallel arrays work in PHP?
    Last edited by ygugsa295; 06-19-2007, 07:50 PM.
  • itmorr
    Custom User Title
    • Jun 2006
    • 1498

    #2
    Re: Question about parallel arrays (PHP)

    I think the instructions mean using two different arrays where the data in array A at index i corresponds to the data in array B at index i. Like use array A for one thing and use array B for another thing, and let them be connected by that index i.




    Originally posted by jwcgator
    (12:31:27 AM) jwcgator2: I got it! I'll write an auto-procrastination program!
    (12:31:33 AM) jwcgator2: meh, i'll make it later

    Comment

    • itmorr
      Custom User Title
      • Jun 2006
      • 1498

      #3
      Re: Question about parallel arrays (PHP)

      Note to everyone who reads this: As tempting as it is, don't click the screensaver link at the bottom of his post.




      Originally posted by jwcgator
      (12:31:27 AM) jwcgator2: I got it! I'll write an auto-procrastination program!
      (12:31:33 AM) jwcgator2: meh, i'll make it later

      Comment

      • ygugsa295
        FFR Player
        • Oct 2006
        • 155

        #4
        Re: Question about parallel arrays (PHP)

        What the fuck is this bullshit, this is even happening on ODI every time I post.

        ps itmorr: bingo.

        pps (OT) i don't want to think of a nude lindsay when she looks like this http://imgsrv.1010wins.com/image/DbG...705/559796.jpg oh god

        edit 4 omfg: what's the syntax like then?
        Last edited by ygugsa295; 06-20-2007, 12:15 AM.

        Comment

        Working...