Resizing a sprite with Pygame Zero

1.3k Views Asked by At

I am making a space invaders game using pgzrun and I am trying to resize a sprite I have.

I tried to research how to do it and I was not able to find a command. There is a command that does it in pygame but I was wondering if there is one for pygame zero.

2

There are 2 best solutions below

0
r0the On

I recommend using Pygame Zero Helper. You have to download the file and add pgzhelper.py to the folder where your Python script resides.

You have to import pgzhelper:

import pgzrun
from pgzhelper import *

Now you can do all sorts of additional stuff, e.g. scaling the sprite:

alien = Actor('alien')
alien.scale = 0.5  # Half size
alien.scale = 2    # Double size
0
CH_cs On

Google brings myself and students here often. Workaround we implement is as follows:

Actor._surf = pygame.transform.scale(Actor._surf, (width, height))