Originally Posted by
manasij7479
I wonder why your function does not take into account the current position of the player.
If it needs to do that too, you'll end up writing a similar function for each 'block' on the map.
Make a grid and return coordinates depending on the arguments (position and movement direction) , instead.
Well, the plan as far as that goes was to define the starting position and write a function for each room and embed within it functions that allowed the player to increase or decrease each function by certain amounts depending on what room they're in (so for example, the clinic would allow the player to increase the north variable and the east variable, but not decrease them, or modify the up or down variable because there are no stairs in that room.
As for why I didn't use an array, well, I started to code that, but it just came out as the equivalent of defining a bunch of variables so that I'd end up with a pile of player cins re-defining them, which is a lot harder to keep track of. Here's the code I started for that:
Code:
//int room[2][2][3]; //new plan, there will be 12 rooms total, the first dimension of the array is north and south, the second dimmension is east and west, the third dimension will be up and down the planned layout is on the following lines:
//Middle level:
// [Meeting Room (north west [1][0][1]) abbreviation: 2] [Tiller's Lab (north east[1][1][1]) abbreviation: 3]
// [clinic (south west [0][0][1]) abbreviation: 1] [Office/Beds (south east[0][1][1]) abbreviation: 4]
// okay, maybe the abbreviations I have above are not as useful for tracking where the player is, but it might be useful for tracking the condition of each room (if something has happened before, rendering it different due to player actions)
// Plan: 1 will be the clinic, 2 will be the meeting room, and so on. It will be important to update this list to keep them clear.
//room[0][0][1]=1;
//room[1][0][1]=2;
//room[1][1][1]=3;
//room[0][1][1]=4;
Now if it was possible to embed functions within those array locations and not just a list of numbers and write a function that was capable of moving the player between locations in the three dimensional array, I'd love to, but I've yet to see a really clear description of how to do that. (Note, I would probably be eternally grateful if you could provide such a thing).