🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Tile based question

Started by
5 comments, last by altair734 24 years, 5 months ago
Does anyone know how to do the part where the player vanishes when you walk behind a tree, but then appears again when you go in front of it? In other words, how do you make the player go behind a tree without appearing in front of it? altair altair734@yahoo.com crawlegend.iwarp.com
altairaltair734@yahoo.comwww.geocities.com/altair734
Advertisement
start drawing your tiles up in the left corner and work your way down. this would cause the character, if blitted behind the tree, to become entirly or partly covered by the tree.
also, if the player and tree happen to be in the same tile, you have to have some way of keeping track of proper z-order (well, i guess it would technically be y order)

Get off my lawn!

To get a player to appear behind things I use layers. I have a base layer that he is alwasy above then I draw him, then I draw a fringe layer where everything that goes over him is drawn. Such as tress, signs, poles, clouds, whatever.

Afastrunner
AKA Camelboy
AfastrunnerAKA Camelboy
Okay guys, I did figure it out, but not with your strategies. The problem with yours is that while he appears behind it, what if he walks in front of it? He will appear behind a tree. Try to figure out that one.

altair
altair734@yahoo.com
crawlegend.iwarp.com
altairaltair734@yahoo.comwww.geocities.com/altair734
Okay I think I got it. All you need to do (as suggested before) is implement a z(y)-buffer and draw the ones overhead first, then draw the below ones. To make the tree, make two tiles. The top one (the one that could be in front of the player) has a y-value of 1. Then make the one that would be behind the player have a y-value of 0.

altair
altair734@yahoo.com
crawlegend.iwarp.com
altairaltair734@yahoo.comwww.geocities.com/altair734
Last year, back in my VB days, I worked on an isometric style rpg which used square ground tiles and free moving sprites (they werent attached to any tile). I also faced this problem and my solution was to exctract all possibly visible sprites from the master sprite array and add them to a smaller array. I then selection sorted this smaller array based on the y location of the object on screen. As you are probably aware, objects closer to the bottom of the screen come in front of further objects in an isometric view, so i just sorted them in such an order that the first item in the new array was rendered first. I found this method very slow, as you could imagine, when handling large numbers of sprites. I am now using the more common and significantly faster and easier method of linking the sprite to a particular tile and rendering it straight after that tile. altairs idea of making any sprite behind the player 1 was what i used untill i needed animated sprites - the npcs who roamed the level and also needed to be zordered.

This topic is closed to new replies.

Advertisement