Text Based Adventure Game Dev Diary: Navigating The Ship

Text Based Adventure Game Dev Diary: Navigating The Ship

Nov 7, 2018. | By: Lewis Bond
1 min

Text Based Adventure Game

For navigating the ship I had pretty good idea of how I was going to do this as I covered it breifly in my last post.

I instantiated two room objects from my room class. A “current room” object and a “next room” object. I did this so it would render the current rooms information to the screen and the “next room” was for checking if the room I wanted to go into was safe or required an item to access it.

This shows the current room information being renderer and then when the player tries to move into the next room, they can't due to the next room requiring an item to access it.

Code

       next_room->updateRoom(current_room->roomExits(i));
       
        if(!next_room->accessible())
        {
            //code here
        }
        else if (next_room->accessible())
        {
            //code here
        }

The code example above is how I did it. So the next room gets updated with the number from ‘current_room->roomExits(i)’ and if it is a viable exit then that number will be between 0-48. It then updates the ‘next_rooms’ values with the data from the element of the vector, mentioned in the previous post, corresponding to the number that was passed in.

PREVIOUS BLOG POSTNEXT BLOG POST

About

Those who can do and those who can't teach games design.

Our Bunker



United Kingdom.