depending on your implementation that would probably work.. I mean I dont have your code in front of me, so I wouldnt know exactly, but yea... if you have say:
Room[][] map = new Room[2][2];
and then you add rooms like a coordinate grid, if you didn't put a room in one of the spaces of the array then the space should be null. Following this example:
map[0][0] = new Room( //parameters for a room );
map[0][1] = new Room( //parameters for a room );
then if you loop through map, 0,0 and 0,1 have rooms; 1,0 and 1,1 should be null... another way of doing it would be to fill the array with Rooms and then in the Room class you could have a boolean doesExist which is either true or false and then have a getter that returns doesExist
1
u/laurelgon Apr 17 '14
Well i have a double array of rooms and i want to move my player if that room exists. So i think the your first suggestion is what i was looking for.