Advertisement
dgdgfgfd

Untitled

Feb 6th, 2022
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. kod:
  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. walkRight = [pygame.image.load('right_1.png'),
  10. pygame.image.load('right_2.png'), pygame.image.load('right_3.png'),
  11. pygame.image.load('right_4.png'), pygame.image.load('right_5.png'),
  12. pygame.image.load('right_6.png')]
  13.  
  14. walkLeft = [pygame.image.load('left_1.png'),
  15. pygame.image.load('left_2.png'), pygame.image.load('left_3.png'),
  16. pygame.image.load('left_4.png'), pygame.image.load('left_5.png'),
  17. pygame.image.load('left_6.png')]
  18.  
  19. bg = pygame.image.load('bg.jpg')
  20.  
  21. playerStand = pygame.image.load('idle.png')
  22.  
  23. clock = pygame.time.Clock
  24.  
  25. x = 50
  26. y = 425
  27. wight = 60
  28. height = 71
  29. speed = 5
  30. isJump = False
  31. JumpCount = 10
  32.  
  33. left = False
  34. right = False
  35. animCount = 0
  36.  
  37. def drawWindow():
  38. global animCount
  39.  
  40. if animCount + 1 >= 30:
  41. animCount = 0
  42.  
  43. if left:
  44. win.blit(walkLeft[animCount// 5], (x, y))
  45. animCount += 1
  46. elif right:
  47. win.blit(walkRight[animCount// 5], (x, y))
  48. animCount += 1
  49. else:
  50. win.blit(playerStand, (x, y))
  51.  
  52. win.blit(bg,(0, 0))
  53. pygame.display.update()
  54.  
  55. run = True
  56. while run:
  57. clock.tick(30)
  58.  
  59. for event in pygame.event.get():
  60. if event.type == pygame.QUIT:
  61. run= False
  62.  
  63. keys = pygame.key.get_pressed()
  64. if keys[pygame.K_LEFT] and x > 5:
  65. x -= speed
  66. left = True
  67. right = False
  68. elif keys[pygame.K_RIGHT] and x < 500 - wight - 5:
  69. x += speed
  70. left = False
  71. right = True
  72. else:
  73. left = False
  74. right = False
  75. animCount = 0
  76. if not(isJump):
  77. if keys[pygame.K_SPACE]:
  78. isJump = True
  79. else:
  80. if JumpCount >= -10:
  81. if JumpCount < 0:
  82. y += (JumpCount ** 2) / 2
  83. else:
  84. y -= (JumpCount ** 2) / 2
  85. JumpCount -= 1
  86.  
  87. else:
  88. isJump = False
  89. JumpCount = 10
  90.  
  91. drawWindow()
  92.  
  93. pygame.quit()
  94. oIIIibka:
  95. Traceback (most recent call last):
  96. File "C:\Users\admin\Desktop\Game\game.py", line 56, in <module>
  97. clock.tick(30)
  98. AttributeError: 'builtin_function_or_method' object has no attribute 'tick'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement