![]() |
Quote:
Inside each section of the array will be a string of 4 letters (eg, "FTTF") which the code will use to determine where it is allowed to move, if the first letter is our ability to go North and it equals F then we cant go north from that area, etc. We can use sub strings to enforce this. Thats my current general plan anyway, this project definitely seems a lot more complex than when I had first envisioned it :P |
Actually, you can just add a single dimensional array as a property within the "location" class which holds 10 integers, each one corresponding to a particular direction. For example, the array could be:
{N,E,W,S,NE,NW,SE,SW,Up,Down} For a particular room, the array might read: {1,0,0,1,0,0,0,0,1,0} which means that he can move north, south and up, but not anywhere else. |
Quote:
And without a multidimensional array wouldnt all the 'areas' lie across the X axis ? meaning that North/South wouldnt take you anywhere. EDIT: Since instead of having to initiate all the variables like this: bool directionUp = true; bool directionDown = true; bool directionEast = true; bool directionNorth = true; etc... I could just put string directionset = "TTTFFT..etc" |
Yeah, I suppose characters do occupy less space than integers, so you can go with the string.
Also I didn't understand what you were saying about the multi-dimensional arrays earlier, but yeah, I guess you'll need a 3D array of pointers which point to particular location objects on the "map". EDIT: Actually, I think using a grid map is a little elaborate. You could just alter the permission string you're using from something like "TFFTFFFT" into {"Meadow","F","F","Living Room","F","F","F","Riverside"}, so that you automatically have the list of accessible locations and their direction. Or if you're using location IDs which I suggest, you can just do {23,0,0,18,0,0,0,7} or something like that. |
All times are GMT. The time now is 10:40 AM. |
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.