Is this possible? I have around 2 weeks for a computer science project and I want to do this in PHP. However, I have just started learning PHP, and since I'm so short on time I'm going to see if I can learn how to code this while learning basics of PHP.
So basically, can anyone give me a simple and good way of starting this? I have no idea where to begin. I was thinking of doing rooms in a coordinate system with North, South, East, West buttons and a pick up item button and an attack button.
So can you guys help? I would also like to know how to make buttons in HTML or anything that goes with Apache 2, I have no idea how that works.

Right now I have PHP set up with Apache 2, so I can navigate to the file with the code in the browser and run the code.

    To be blunt I think this is beyond someone who's just beginning given the time frame. I don't mean to discourage or offend you but perhaps there's a different application or something you could tackle?

    If you do decide to do this, a coordinate system would work. Store the player's position in a variable based on where they move. When the game "loads" you'll probably want to pregenerate the "map" so you can check if the player is moving off the board or into a wall, etc.

    Good luck!

      Sir, YOU UNDERESTIMATE MY POWER.

      Hehe, anyways, thanks, but how do I do this coordinate system 😢

        Well let's say the map is 10 squares by 10 squares. Every square will have a coordinate, so if you were at the bottom left of the map you'd be at coordinates 1,1. If you were at the top right of the map you'd be at 10,10. You could store the coordinates in an array with two elements, one for the Y axis and one for the X axis. Or store them as two separate values, whichever you're more comfortable with.

        Just remember you'll have to update (and check) these values as the player moves around your map.

          But I am still very confused. How do I assign rooms these coordinates?

            I would recommend defining a two-dimensional [man]array[/man].

            // create 2 x 2 array matrix called $map:
            $map = array();
            for($x=0; $x<10; $x++) {
              // create row $x -- a nested array!
              $map[$x] = array();
              for($y=0; $y<10; $y++) {
                // within row $x, create an associative array to describe the contents of each point on this row
                $map[$x][$y ] = array(
                  'clue' => NULL;
                  'treasure' => NULL;
                  'monster' => NULL;
                );
              }
            }
            
            //Then you can assign clues, treasures, and monsters to coordinate x=2, y=3 on the map like so
            $map[2][3]['clue'] = "You find a glowing sword! Watch out for monsters nearby!";
            $map[2][3]['treasure'] = "DRAGON_SLAYING_SWORD";
            $map[2][3]['monster'] = NULL; // no monster
            
            // then assign a the next coordinate over
            $map[3][3]['clue'] = "OH **** A DRAGON!";
            $map[3][3]['treasure'] = "100 gold pieces";
            $map[3][3]['monster'] = "Red Dragon, 100HP, 10D10 DAMAGE";
            

            I've just assigned simple strings for clues, etc. in this case, but in reality you would probably use more complex objects.

            The other logic is up to you.

              Write a Reply...