Java Isometric Depth (not diamond)

195 views Asked by At

So I had a quick question. I'm currently making a small game in java and I wanted to experiment with hiding the player behind fake 3D objects on the screen (Isometric drawing). Unfortunately I can't post a picture (Not enough rep). Basically it's a 3D block that is 32 by 48 that gives an illusion that it's 3D by having half of it a lighter color and the other half a darker one. The player is the same size as the block and can move freely around the map of these 'blocks'. If the player moves behind a block, it's bottom part is hidden behind it. The opposite when it moves in front, covering the non-player block. Now I made an example program in GameMaker Studio just to test it out. To make it work in GM, I made a script for each sprite that was one line of code:

depth = y * -1

This causes the bottom part of the player to 'hide' behind the blocks when it moves behind them. I looked into it a bit on GM's wiki and it's pretty much changing the 'depth' of the instances. Now my question is, how would I do something like this in Java?

P.S. This is not in a diamond. It is in a straight 2D world (looking 45 down towards objects from front).

EDIT: Here are some pictures of the GameMaker version:

Player Outside

Player Inside

2

There are 2 answers

0
moltom26 On BEST ANSWER

Thanks to Kayaman for solving the problem:

If you draw your player first, then a wall on the block south of it, the top half of the wall will mask the bottom half of the player. So no, you don't need to draw halves separately. This means of course that you need to draw the player at the same time as the map, so you can't first draw the map and then the player.

Just for future use, layering images in java is determined by the order in which they are added. This was the exact answer I was looking for. The GM code was GameMaker's way of setting the order in which the images were added to the screen.

Thanks to everyone for the help!

10
Verhagen On

Read about drawing isometric worlds. Read about Java and isometric development.