Java2D, 2.5D affect help

I really need help with this, so I have a pretty good 2.5D affect going

picture of game so far

but one problem, I don;t know how to draw the player behind it if they have a lower Y or X, looping through all the objects doesn’t work, it only works on the last object added to my game and all the rest look like this when you get close

all the objects and players are in an arraylist and looping though all checking X and Y doesn’t work!

You will want to sort your sprites by z-order before rendering them.

Ha, its a puzzle!

In the case that there is no Z to speak if, in this case: wouldn’t drawing objects in order of top to bottom solve this particular issue without even needing to do any kind of checks? Probably there will be other collision issues going on in other situations (especially when dealing with particularly small objects), but you take these kind of things one step at a time.

You just need to draw in the right order: terrain, characters, walls [EDIT: doh, forgot to add “for each horizontal row, top to bottom”]. You’ll have to get smart about either placing or removing walls when they would obscure important detail, which is what all other “forced perspective” 2d games do. There’s a funny joke in ultima 7 where they give some silly explanation about why all the houses only have doors on the south or east side.

ahh thanks, I searched up zbuffering and I got this great idea, I added my obstacles and players into a arraylist of Objects and then I sorted them so that people/obstacles lower on the Y axis would have a lower index(therefore painted first) than people high on the Y axis(high index, painted last)

That’s exactly how it’s done, nice!