Skip to main content
Post Reopened by Vaillancourt
added 15 characters in body; edited tags; edited title
Source Link

Java or Python Game Library Rotating a sprite with Pyglet without changing its X and Y

Situation: I'm going to makeI have code which rotates a 2d top-down multiplayer tank game, but no Python sprite libraries I've found have been what I wanted.:

@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

RequirementsHowever, this rotates the sprite in a manner I don't want: it changes its x and y position. I need to be ablewant it to display spritesremain in the same place -- it's a tank, and either rotate those sprites about an axis or display different frames depicting rotation (I already have the images)is not supposed to move when it turns. SupportIf, for transparency is a mustinstance, as my .png files are transparent.I do

player_sprite.rotation = 180

What I've tried: I've tried Pygletit not only faces the opposite direction, but its rotation of sprites doesn't keep the sprite inis now far away from its original X and Y coords. Pygame is too large,x and yields errors with pip is usedy coordinate.

Question: Please reccomend How would I allow the sprite to merotate without changing its x and y?

Here's a library for either Python or Javalink to my (preferrably Python) that is cross-platform, supports sprites, and can rotate themfull code.

Java or Python Game Library

Situation: I'm going to make a 2d top-down multiplayer tank game, but no Python sprite libraries I've found have been what I wanted.

Requirements: I need to be able to display sprites, and either rotate those sprites about an axis or display different frames depicting rotation (I already have the images). Support for transparency is a must, as my .png files are transparent.

What I've tried: I've tried Pyglet, but its rotation of sprites doesn't keep the sprite in its original X and Y coords. Pygame is too large, and yields errors with pip is used.

Question: Please reccomend to me a library for either Python or Java (preferrably Python) that is cross-platform, supports sprites, and can rotate them.

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.

Post Closed as "Not suitable for this site" by Vaillancourt
Source Link

Java or Python Game Library

Situation: I'm going to make a 2d top-down multiplayer tank game, but no Python sprite libraries I've found have been what I wanted.

Requirements: I need to be able to display sprites, and either rotate those sprites about an axis or display different frames depicting rotation (I already have the images). Support for transparency is a must, as my .png files are transparent.

What I've tried: I've tried Pyglet, but its rotation of sprites doesn't keep the sprite in its original X and Y coords. Pygame is too large, and yields errors with pip is used.

Question: Please reccomend to me a library for either Python or Java (preferrably Python) that is cross-platform, supports sprites, and can rotate them.