Цитата (goldsphere)
player.angle = atan2(player.x-mouse.x, player.y-mouse.y)
я так уже пробовал. идет вращение по кругу при нажатии, а мне надо именно чтобы спрайт следил за курсоромКод
float angle = (float) Math.atan2(DonutDefender.player.position.x-getMouseX(), DonutDefender.player.position.y-getMouseY());
GL11.glRotatef(angle, 0.0f, 0.0f, 1.0f);
Вот класс игрока
Код
public class Player {
public Texture texture;
public Vector3f position;
public Player(){
position = new Vector3f(100.0f, 100.0f, 0.0f);
}
public void LoadTexture(){
try {
texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/graphics/player/spaceship.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
public void Render(){
this.texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex2f(position.x, position.y);
GL11.glTexCoord2f(1,0);
GL11.glVertex2f(position.x+texture.getTextureWidth(), position.y);
GL11.glTexCoord2f(1,1);
GL11.glVertex2f(position.x+texture.getTextureWidth(), position.y+texture.getTextureHeight());
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(position.x, position.y+texture.getTextureHeight());
GL11.glEnd();
}
}