Java Slick2d - How to translate mouse coordinates to world coordinates

Posted by SYNYST3R1 on Stack Overflow See other posts from Stack Overflow or by SYNYST3R1
Published on 2012-04-11T04:39:53Z Indexed on 2012/04/11 5:28 UTC
Read the original article Hit count: 384

Filed under:
|
|
|

I am translating in my main class' render. How do I get the mouse position based on the translation?

public void render(GameContainer gc, Graphics g) 
        throws SlickException 
{
    float centerX = 800/2;
    float centerY = 600/2;
    g.translate(centerX, centerY);
    g.translate(-player.playerX, -player.playerY);
    gen.render(g);
    player.render(g);
}

playerX = 800 /2 - sprite.getWidth();
playerY = 600 /2 - sprite.getHeight();

I update the player position on keydown by .2f * delta

Picture to help with explanation

i92.photobucket.com/albums/l22/occ31191/Untitled-4.png

© Stack Overflow or respective owner

Related posts about java

Related posts about mouse