PerspexSphinx
Posts: 6
Joined: Fri Feb 16, 2018 10:36 pm

Re-scale an actor in pgzero?

Fri Oct 05, 2018 7:10 pm

Hi,
Maybe I’m missing something obvious but…
…is there a way to re-scale an actor (sprite) in pgzero?

User avatar
B.Goode
Posts: 7858
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Re-scale an actor in pgzero?

Sun Oct 07, 2018 7:52 am

At https://pygame-zero.readthedocs.io/en/l ... in-objects
it says -
Actors have all the same attributes and methods as Rect

And at https://www.pygame.org/docs/ref/rect.html

there is a method .inflate()

https://www.pygame.org/docs/ref/rect.ht ... ct.inflate


Disclaimer: not a user of PygameZero, just an avid reader of documentation...

PerspexSphinx
Posts: 6
Joined: Fri Feb 16, 2018 10:36 pm

Re: Re-scale an actor in pgzero?

Wed Oct 17, 2018 5:46 pm

Sorry I’m not the greatest of programmers,
I tried messing around with your suggestion, but am still confused, shorly this should be simple to acchive since Py Game Zero is supposed to be simpler than PyGame...
...could some kind, conscience person post a simple example piece of code which re-scales an Actor (sprite)?

User avatar
B.Goode
Posts: 7858
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Re-scale an actor in pgzero?

Wed Oct 17, 2018 8:27 pm

could some kind, conscience person post a simple example



Well that excludes me...

But some other thoughts -

Regarding Simplicity. See the Principles of Pygame Zero documentation: https://pygame-zero.readthedocs.io/en/s ... iples.html
Pygame Zero wraps Pygame almost completely - but we don’t expose all the features. We expose only the features that work really well without extra fuss, and hide some of the other features that work less well or need extra steps.
Maybe Simplicity is bought at the cost of Functionality?




The Flappy Bird example in that documentation includes multiple images of the bird to simulate movement. Maybe you could scale your images in dedicated image handling software outside of PGZ and store the results for use in the script.




Finally. This is a package that will run on multiple different Operating Systems. A solution is unlikely to be specific to the Raspberry Pi (Raspbian) version. Perhaps you would get informed advice from the developer or other users via the GitHub issues page: https://pygame-zero.readthedocs.io/en/s ... uting.html

PerspexSphinx
Posts: 6
Joined: Fri Feb 16, 2018 10:36 pm

Re: Re-scale an actor in pgzero?

Thu Oct 18, 2018 4:12 pm

Ooops, also spelling is not one of my fortes…
…but honestly, re-scaling a sprite should not be “alchemy” when it’s supper simple to rotate an Actor (sprite)!
There have been a number of recent articles in “MagPi Magazine,” but they conveniently never broach the subject…
…is it simply not achievable in Py Game Zero?
Ooops,
…Oh, earlier…
…I meant SUPER…
…which I think Py Game Zero is by the way!!!
…I’m just a bit mystified....
…but,
…I thank you for your insights…
…but again what other game engine out there can’t re-scale a sprite????

User avatar
B.Goode
Posts: 7858
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Re-scale an actor in pgzero?

Thu Oct 18, 2018 5:18 pm

re-scaling a sprite should not be “alchemy” when it’s su[p]per simple to rotate an Actor (sprite)!

As already suggested, give that feedback to the developer/maintainer.

You can report bugs, or request features that you think should be in Pygame Zero, using the Github issue tracker.
https://github.com/lordmauve/pgzero/issues

PerspexSphinx
Posts: 6
Joined: Fri Feb 16, 2018 10:36 pm

Re: Re-scale an actor in pgzero?

Mon Nov 05, 2018 6:54 am

Thank you, B.Goode....

I have taken your kind advice and have posted my query to the developer/maintainer on GitHub (which is a kind of silly name if you ask me).

MrZhangEPSB
Posts: 2
Joined: Tue Nov 28, 2017 8:08 pm

Re: Re-scale an actor in pgzero?

Sat Jul 06, 2019 11:57 pm

Hi!

I don't know if you still need this, but you need to use the pygame package that pygame zero is based on.

Code: Select all

import pgzrun
import pygame

alien = Actor('alien')
alien._surf = pygame.transform.scale(alien._surf, (new_width, new_height))
alien._update_pos()

def draw():
	alien.draw()

pgzrun.go()
The first line (alien._surf = pygame....) resizes the image.
The second line (alien._update_...) updates the anchors (i.e. alien.right, etc.)

I didn't test extensively, but hopefully that helps!

Return to “Gaming”