Skip to content

Enhancement: Add support for rotation offsets for sprites (anchor) #1102

@pushfoo

Description

@pushfoo

Enhancement request:

What should be added/changed?

tl;dr: Add rotation angle offset support for sprites

This would take the form of angle_offset and radians_offset to match the respective attributes of Sprite. To avoid conflict between the two settings, the default values could be None, raising an exception if both receive non-None values.

Different Sprite subclasses could also have different default values to make use of sprites as they're found.

The implementation could be one of the following:

  • Extra parameters for load_texture or Texture, with pass-through versions of the args in Sprite's constructor
  • Class variable
  • Instance variable set from constructor argument + property
  • Mix of the above

Each option seems to potential have advantages as well as disadvantages.

What would it help with?

tl;dr: Increase development speed

Although flipped_horizontally and flipped_vertically are supported as arguments to Sprite, these don't allow for rotation that would be useful for non-symmetrical sprites.

Adding rotation support would:

User Story Example

Alex is a student working on a top-down game on a somewhat underpowered computer. He finds a good image of a vehicle, but it points the wrong way when loaded into arcade. Alex passes -90 to angle_offset to immediately make the image load correctly. No time is wasted on waiting for an image editor to load.

Possible advantages of different implementations

Option Advantage
Extra parameters to load_texture or Texture, mirrored in Sprite's constructor Improves texture loading flexibility in general
Class variable Allows introducing users to the idea of a class variable in Python
Instance variables Could make creating some interesting game behavior easier
A mix Flexibility

Class variables could be confusing to beginners, so they might not be the best default interface for this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions