Alex Plue Alex Plue - 5 months ago 24
Python Question

Pygame inflate not working

So I'm making a game using python and I'm looking to make a rectangle grow.

I saw on the pygame website that you use the inflate method and saw a demo of it and tried it but it does not work.

Here is my code:

# defining statement
player = Rect(300, 100, 50, 50)
grow = player.inflate(100, 100)

# calling statement
if player.colliderect(food):
foods.remove(food)
grow

Answer

grow is a variable, and it is not callable.

If you want to inflate the player, do this -

player = Rect(300, 100, 50, 50)

if player.colliderect(food):
            foods.remove(food)
            player = player.inflate(100, 100)