Problem In Speed Of Animation In Python(pygame)
I am making a ninja game in which a ninja has to dodge obstacle by jumping(pressing spacebar), but the jump animation is too fast and the ninja is not able to jump beyond the obsta
Solution 1:
possible solution, add a varibles:
speedJump = 2# play with this value, try to decrease and increaseninjaDirect = None
and in the main loop:
while True: # main loopif ninjaDirect == "down":
if player + 100 >= y:
# we in middle of jump
player.y += speedJump
else: # we finish the jump
ninjaDirect = None
player.y = y
...
foreventin pygame.event.get():
...
ifevent.type == pygame.KEYDOWN: #keydownifevent.key == pygame.K_SPACE:
if player.y > 100:
ninjaDirect = "up"
player.y -= speedJump
else: ninjaDirect = "down"ifevent.type == pygame.KEYUP: #keyupifevent.key == pygame.K_SPACE:
ninjaDirect = "down"
...
Post a Comment for "Problem In Speed Of Animation In Python(pygame)"