As you might see, here's where I run into trouble. The buildings are randomly placed, and if their masks collide with one another they jump to new locations. However, if they land collision-free, some tend to hover over others in the air. I'm trying to determine how to set the buildings' depth in the Draw event so that this is a nonissue. Do any of you have suggestions?
One way to cheat around the problem would be to have them be completely solid when they are placed, but I later plan to have a character that can walk amongst the buildings, and I'd like as much convincing depth as possible. The variables that each building possesses for position are as follows:
x,y : these are at the top-left corner of the sprite.
w,h : the width and height of the buildings in "units."
sc: scale of the units. Currently at 16 px.
d: depth of the building in units, but not instance depth. This is how far diagonally back the building is drawn.
The sprite is then (w+d)*sc x (h+d)*sc in size. Have any of you solved this problem before? Oblique projection seems like a method that more people would be familiar with, but there's very little internet literature on the subject. Thanks!
EDIT: I just reread the guidelines, so here's a sample of the code I was using for depth in the screenshot. This is in the Draw event for each building:
depth = -1*(((y+h)/sc)+((x+d)/sc)); draw_sprite(bspr,0,x,y); //draw_text(x,y-16,string((x+d)/sc) + ', ' + string((y+h)/sc) + ', ' + string(depth));
Edited by hypothete, 26 March 2010 - 08:28 PM.