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 increase
ninjaDirect = None
and in the main loop:
while True: # main loop
if ninjaDirect == "down":
if player + 100 >= y:
# we in middle of jump
player.y += speedJump
else: # we finish the jump
ninjaDirect = None
player.y = y
...
for event in pygame.event.get():
...
if event.type == pygame.KEYDOWN: #keydown
if event.key == pygame.K_SPACE:
if player.y > 100:
ninjaDirect = "up"
player.y -= speedJump
else: ninjaDirect = "down"
if event.type == pygame.KEYUP: #keyup
if event.key == pygame.K_SPACE:
ninjaDirect = "down"
...
Post a Comment for "Problem In Speed Of Animation In Python(pygame)"