0
votes

While drawing graphics in 2D, how can I handle the depth of a picture in the frame? For example the ground would be depth -1 and the player depth 0?

And another question how do I achieve this kind of looking ground? When I say achieve, I mean just the theoretical way of doing it not actual source code, but source code could help.

enter image description here

My game is Tile based already and it is ready to be drawn in isometric. I have x y and z coordinates in the engine part of the game. I read that you need to translate it into only x and y for drawing in isometric but I'm not sure how or why would i do that.

Here is a picture of my game right now. The coin is the player, and the squares are the Tiles.

enter image description here

One last thing my Tiles are stored in an array, i.e Tile[] tileList. Is that an efficient way of storing it? Because I want the best performance I can get out of my game.

Thank you very much.

1
The depth is implemented by just drawing the floor tiles first and then the character(s) (for now). You will make your tile images so they are isometric to begin with, like these tiles, for example. Finally, for 1 row of iso tiles on your screen, it holds that x + y == row (in 1 possible representation); so the 3rd row (row == 2) would have tiles (2,0), (1,1) and (0,2).Torious
Arrays are very memory-efficient. Java apparently isn't that good at doing lookups in them, but as far as I know every alternative for the array (like the ArrayList) is a fancy encapsulation of one or more arrays. It really depends on what data your Tile class holds to say something about whether it is possible to improve. If it would, say, only hold the colour of tiles, you could just make an int array instead. But something like that really depends on your implementation and requirements.Bartvbl
Thanks! That helped me a lot!Amit Assaraf

1 Answers

0
votes

I did a simple depth perception in my 3D display. The basic equation for depth perception is: perceived size = size/distance, that's it. So for each 3D point, I set their corresponding perceived 2D sizes: x2D = x3D/(zoom - z3D), and y2D = y3D/(zoom - z3D). where zoom is your distance from the origin of your axis. Does this answer you depth question?