Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- pygame.init()
- win = pygame.display.set_mode((500, 500))
- pygame.display.set_caption("amaan dheere")
- screenwidht = 500
- x = 50
- y = 425
- width = 40
- vel = 5
- height = 6
- isJump = False
- jumpCount = 10
- run = True
- while run:
- pygame.time.delay(100)
- 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 > vel:
- x -= vel
- if keys[pygame.K_RIGHT] and x < 500 - width - vel:
- x += vel
- if not(isJump):
- if keys[pygame.K_UP] and y > vel:
- y -= vel
- if keys[pygame.K_DOWN] and y < 500 - height - vel:
- y += vel
- if keys[pygame.K_SPACE]:
- isJump = True
- else:
- if jumpCount >= -10:
- neg = 1
- if jumpCount < 0:
- neg = -1
- y -= (jumpCount ** 2) * 0.5 * neg
- jumpCount -= 1
- else:
- isjump = False
- jumpCount = 10
- win.fill((0, 0, 0))
- pygame.draw.rect(win, (255,0,0),(x, y, width, height))
- pygame.display.update()
- pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement