python - Moving a Sprite Back and Forth in pygame -


i have sprite going on end of screen other, want go , forth forever. ideas?

u = 1 #u x coordinate if u < 430: #480 window siz, want stop @ 430    u += 5 # move 5 

should add whole code easier?

you can use delta variable:

delta = 5 u = 1 

and have adjusted switch directions:

u += delta if u >= 430:     delta = -5 elif u < 50:    delta = 5 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -