2D Isometric View

Excuse me if I am posting this in the wrong board.
So I thought about working on a new game as just a fun project to learn with. I’m going for a view similar to that of Diablo 1, how would I go for getting a 2D Isometric view? I’m not using any extra libraries such as LibGDX or Slick2D.

All help is appreciated :).

Very, very, very helpful read:
http://www.java-gaming.org/topics/drawing-isometric-tiles-inside-a-screen/24922/msg/212780/view.html

Oh wow, thank you VERY much, this really helped me out.

You can also use vector math. I have some Scala code here that shows how to translate coordinates in any arbitrary coordinate system into screen coordinates and back.
http://pastebin.com/qKjxeCPj

YES! Another scala guy! Awesome!

what exactly do the second and third argument for the CoordinateSystem mean?

The last two arguments represent the x and y axis of the coordinate system.
The x axis vector for example points from the origin to the point (1,0) in the target coordinate system.
So if you define your isometric system as


CoordinateSystem(Vec(500,100),
                 Vec(1,1),
                 Vec(-1,1))

the point (0,0) corresponds to the screen coordinates (500,100). And the two axis of the isometric system point downwards 45degrees like in this image.

So (1,0) in the game means (1,1) + origin in screen coordinates.

Awesome! understood that, really awesome…! :slight_smile:

Do those axis vectors need to be normalized, or is it okay to have them un-normalized, or what would be the effect of having them big? The values scale?
So If I have Vec(10, 0) for x and Vec(0, 10) for y, and I’d convert Vec(1, 1), I’d get Vec(10, 10)? (scaled?)

Yes, exactly. The vectors give the directions of the axes and also the scale. So the CoordinateSystem class can represent scaling, rotation, translation and also shearing (http://cs.fit.edu/~wds/classes/cse5255/thesis/shear/shear.html) since the two axes don’t need to have a right angle between them.
I improved the CoordinateSystem class to make rotating and scaling easier. As you can see I like to work with immutable objects. At least when it comes to mathematical entities like vectors, matrices or even coordinate systems. Entities in a game however I usually make mutable.
http://pastebin.com/6XaMHgyU

Wow… with that you could…
actually make a rotating isometric viewport, by simply rotating the axes!

But in the end you’d probably be better off with letting opengl do that kind of stuff, but still very, very cool! :slight_smile:

Yes, if you use libgdx you can use the Stage and Camera classes to do these things and more. But if you don’t want to use any libraries and it’s a relatively simple 2D game my solution is a good fit. However instead of having a class called CoordinateSystem it may be better to have a Camera class. A camera is basically defined oppositly to the CoordinateSystem class i.e. the camera’s position and orientation are relative to the game world.