Advertisement
dgdgfgfd

Untitled

Feb 5th, 2022
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. ПОЧЕМУ МОДЕЛЬКА ПРЫГАЕТ БЕСКОНЕЧНО ПРИ НАЖАТИЕ SPACE
  2. import pygame
  3.  
  4. pygame.init()
  5. win = pygame.display.set_mode((500,500))
  6.  
  7. pygame.display.set_caption("VLAD.EXE")
  8.  
  9. x = 50
  10. y = 425
  11. wight = 40
  12. height = 60
  13. speed = 10
  14. isJump = False
  15. JumpCount = 10
  16.  
  17. run = True
  18. while run:
  19. pygame.time.delay(50)
  20.  
  21. for event in pygame.event.get():
  22. if event.type == pygame.QUIT:
  23. run= False
  24.  
  25. keys = pygame.key.get_pressed()
  26. if keys[pygame.K_LEFT] and x > 5:
  27. x -= speed
  28. if keys[pygame.K_RIGHT] and x < 500 - wight - 5:
  29. x += speed
  30. if not(isJump):
  31. if keys[pygame.K_UP] and y > 5:
  32. y -= speed
  33. if keys[pygame.K_DOWN] and y < 500 - wight - 15:
  34. y += speed
  35. if keys[pygame.K_SPACE]:
  36. isJump = True
  37. else:
  38. if JumpCount >= -10:
  39. if JumpCount < 0:
  40. y += (JumpCount ** 2) / 2
  41. else:
  42. y -= (JumpCount ** 2) / 2
  43. JumpCount -= 1
  44.  
  45. else:
  46. isJamp = False
  47. JumpCount = 10
  48.  
  49.  
  50. win.fill((0, 0, 0))
  51. pygame.draw.rect(win, (0, 0, 250), (x, y, wight, height))
  52. pygame.display.update()
  53. pygame.quit()
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement