0
\$\begingroup\$

I'm making a 2D isometric tiled game using LibGDX. In my Player class, I created a vector2 that I named 'pos' to manage the player position, then I draw my Player with:

    batch.begin();
    batch.draw(localPlayer.texture,LocalPlayer.pos.x,LocalPlayer.pos.y);
    batch.end();

Let's say pos = (0,0), then the Player will be rendered at the bottom left corner of my screen.

When I translate the camera, the (0,0) still correspond with the bottom left of my screen, so the pos Vector2 is about my screen, not my map...

What should I do to get a Coordinate System based on the map and not on my screen? I would not prefer using the Sprite Class...

Thank you :)

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

Have a look at model view protection matrix (matrix transformations): http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/

This is related to OpenGL, but the operations are similar in any library.

\$\endgroup\$
3
  • \$\begingroup\$ Basically model Is the position I the map...view is the position on the screen...projection is either ortho or persp \$\endgroup\$ Nov 13, 2016 at 7:28
  • 1
    \$\begingroup\$ This is good, however with LibGDX you can do it automaticly by calling >batch.setProjectionMatrix(camera.combined) \$\endgroup\$ Nov 17, 2016 at 11:06
  • \$\begingroup\$ Yeah..it depends in the framework. But the concept was same. Btw I am an openGL guy \$\endgroup\$ Nov 17, 2016 at 11:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .