Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rotation/scale/flip for Actor #3

Open
lordmauve opened this issue May 25, 2015 · 4 comments
Open

Support rotation/scale/flip for Actor #3

lordmauve opened this issue May 25, 2015 · 4 comments

Comments

@lordmauve
Copy link
Owner

Originally reported by: Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve)


Pygame supports somewhat slow rotation, scale and flip operations in software.

We should expose these for the Actor class.

May depend on issue #2, which allows users to specify an "anchor point" around which the actor will rotate.

Open questions: how should these operations affect the actor's bounding rect?


@lordmauve
Copy link
Owner Author

Original comment by Daniel Pope (Bitbucket: lordmauve, GitHub: lordmauve):


I had it in mind that this would be a property, eg:

actor.rotation = 1.5 * math.pi
actor.flip_x = True

However this has the drawback of needing an implied order for the transform. Maybe it could be CSS3 transform style?:

alien = Actor('alien')
alien.transform = 'rotate(5deg) scaleX(-1)'

@dryabov
Copy link

dryabov commented Aug 4, 2018

+1

My son asked me how to flip the alien image (to move it in the opposite direction), and the only solution I found (in addition to pre-creation of flipping image in an image editor) is:

from pygame.transform import flip

def draw():
    if direction > 0:
        alien.draw()
    else:
        screen.blit(flip(alien._surf, True, False), alien.topleft)

It would be nice to get it in a simpler way out of the box.

@lordmauve
Copy link
Owner Author

@a96tudor has been working on scale/flip at the recent Europython sprints.

The proposed API is to set alien.scale_x = -1 - I wonder if that's what your son would guess?

@dryabov
Copy link

dryabov commented Aug 4, 2018

Exactly. Currently he uses direction variable to move the alien with alien.left += 2 * direction, so that alien.scale_x = direction seems to be an ideal and clear solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants