1
votes

Im making a game in pygame and need to reset my.player at the bottom of the screen after a certain y value is reached. I can get that to work by setting the self.y and self.x variables in the sprite class equal to the coordinates that i want, but then the sprite cant move since it is fixed to those positions. Any help ?

1
Showing the relevant code will get you more responses. - vdbuilder
Create a property named rect that sets coords as float, but returns a rect. - ninMonkey

1 Answers

0
votes

The problem is probably that the command for fixing the sprite position gets stuck in the loop after the first "activation". For instance: A part like this

stop = False
spritepositionfixed = True
while not stop:
    if y > #Your Max Y value:
        spritepositionfixed = True
    if spritepositionfixed:
        sprite.x = coordinatex
        sprite.y = coordinatey

would set the sprite position always after the first time it reached the y coordinate. You should change it to something like this:

stop = False
while not stop:
    if y > #Your Max Y value:
        sprite.x = coordinatex
        sprite.y = coordinatey

Hope it helped :)