PDA

View Full Version : doors in tile based games


theMonitor
01-15-2004, 06:55 AM
i'm going through tony pa's tutorials on tile-based games and have a question relating to the way he organises doors between maps

http://www.tonypa.pri.ee/tbw/tut06.html

here is the door code:


game.Doors = function (newmap, newcharx, newchary) {
this.newmap=newmap;
this.newcharx=newcharx;
this.newchary=newchary;
};

game.Doors.prototype.walkable = true;
game.Doors.prototype.frame = 3;
game.Doors.prototype.door = true;
game.Tile2 = function () { };
game.Tile2.prototype = new game.Doors(2, 1, 4);
game.Tile3 = function () { };
game.Tile3.prototype = new game.Doors(1, 6, 4);


doing it this way, every door you place on your maps is going to look the same (ie 'frame three' of the map component movie clip). waht's the most efficient way to amend this so that each door (Tilex) could have one of, say, four graphics (so it can be installed n, s, e, w).

thanks in advance for any suggestions

||| O ^ | + O ¬

Marz
01-15-2004, 11:54 PM
I'll check it out sometime then.. When I have some free time.. I really don't like his coding methods though.. But.. Hey.. Can't please everyone can we? :D

theMonitor
01-19-2004, 08:27 AM
thanks. brilliant. looking forward to any analysis or suggestions.

cheers

||| O ^ | + O ¬

littlered
01-19-2004, 12:04 PM
the way I went about it was to have a separate doors array. It probably involved a bit more work, but it meant I could use any (walkable) tile as a door. So you could draw a different graphic for each N, E, S and W door and hold that information in your map array.
My door array then had the following information for each door:
the x and y coordinates of the door, the new map number that you would be taken to and the new x and y coordinates of the hero once on the new map.

my main loop then just checked through the current doors array to see if the hero was on one of the door tiles and if it was, the new map was drawn, the hero was repositioned etc.

does this help at all?

junahu
01-20-2004, 07:28 AM
Huh? Those aren't doors. Those are teleports. Doors are tiles that block your way until you 'open' them.

littlered
01-21-2004, 03:33 AM
sorry, 'doorways' then.

the reason for the having new coords of the hero was so that when the hero went off the right hand side on to a new map, they appeared on the left hand side of that map. I could have coded it so that it was worked out automatically, but at the time it seemed easier to just enter them into the array.