Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- kod:
- import pygame
- pygame.init()
- win = pygame.display.set_mode((500,500))
- pygame.display.set_caption("VLAD.EXE")
- walkRight = [pygame.image.load('right_1.png'),
- pygame.image.load('right_2.png'), pygame.image.load('right_3.png'),
- pygame.image.load('right_4.png'), pygame.image.load('right_5.png'),
- pygame.image.load('right_6.png')]
- walkLeft = [pygame.image.load('left_1.png'),
- pygame.image.load('left_2.png'), pygame.image.load('left_3.png'),
- pygame.image.load('left_4.png'), pygame.image.load('left_5.png'),
- pygame.image.load('left_6.png')]
- bg = pygame.image.load('bg.jpg')
- playerStand = pygame.image.load('idle.png')
- clock = pygame.time.Clock
- x = 50
- y = 425
- wight = 60
- height = 71
- speed = 5
- isJump = False
- JumpCount = 10
- left = False
- right = False
- animCount = 0
- def drawWindow():
- global animCount
- if animCount + 1 >= 30:
- animCount = 0
- if left:
- win.blit(walkLeft[animCount// 5], (x, y))
- animCount += 1
- elif right:
- win.blit(walkRight[animCount// 5], (x, y))
- animCount += 1
- else:
- win.blit(playerStand, (x, y))
- win.blit(bg,(0, 0))
- pygame.display.update()
- run = True
- while run:
- clock.tick(30)
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- run= False
- keys = pygame.key.get_pressed()
- if keys[pygame.K_LEFT] and x > 5:
- x -= speed
- left = True
- right = False
- elif keys[pygame.K_RIGHT] and x < 500 - wight - 5:
- x += speed
- left = False
- right = True
- else:
- left = False
- right = False
- animCount = 0
- if not(isJump):
- if keys[pygame.K_SPACE]:
- isJump = True
- else:
- if JumpCount >= -10:
- if JumpCount < 0:
- y += (JumpCount ** 2) / 2
- else:
- y -= (JumpCount ** 2) / 2
- JumpCount -= 1
- else:
- isJump = False
- JumpCount = 10
- drawWindow()
- pygame.quit()
- oIIIibka:
- Traceback (most recent call last):
- File "C:\Users\admin\Desktop\Game\game.py", line 56, in <module>
- clock.tick(30)
- AttributeError: 'builtin_function_or_method' object has no attribute 'tick'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement