# Rotating a sprite with Pyglet without changing its X and Y

I have code which rotates a sprite:

@window.event
def on_key_press(symbol, modifiers):
print('Rotating')

global player_sprite

player_sprite.rotation += 1

if player_sprite.rotation == 360:
player_sprite.rotation = 0


However, this rotates the sprite in a manner I don't want: it changes its x and y position. I want it to remain in the same place -- it's a tank, and is not supposed to move when it turns. If, for instance, I do

player_sprite.rotation = 180


it not only faces the opposite direction, but is now far away from its original x and y coordinate.

How would I allow the sprite to rotate without changing its x and y?

Here's a link to my full code.

• Is this answer useful? – Vaillancourt May 29 '19 at 19:23
• Perfect! Merci mille fois! – user96931 May 29 '19 at 19:30