PhilipCander

Untitled

Oct 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import pygame
  2. pygame.init()
  3.  
  4. # Window settings
  5. size = [600, 500]
  6. win = pygame.display.set_mode(size)
  7.  
  8. # Player Settings
  9. jump = False
  10. jumpcount = 10
  11. y = 430
  12.  
  13. enemyX = 600
  14. def enemy():
  15. global enemyX
  16. enemyX -= 5
  17. pygame.draw.rect(win, (0, 150, 0), (enemyX, 450, 50, 50))
  18.  
  19. run = True
  20. # Clock function
  21. clock = pygame.time.Clock()
  22. while run:
  23. clock.tick(30)
  24. # Checking for QUIT event
  25. for event in pygame.event.get():
  26. if event.type == pygame.QUIT:
  27. run = False
  28.  
  29. # keys is event for KEY-press
  30. keys = pygame.key.get_pressed()
  31.  
  32. if not jump:
  33. if keys[pygame.K_SPACE]:
  34. jump = True
  35. else:
  36. if jumpcount >= -10:
  37. neg = 1
  38. if jumpcount < 0:
  39. neg = -1
  40. y -= (jumpcount ** 2) * 0.5 * neg
  41. jumpcount -= 1
  42. else:
  43. jump = False
  44. jumpcount = 10
  45.  
  46. hitboxX = 30
  47. hitboxY = y
  48.  
  49. if hitboxX + 70 >= enemyX and hitboxY >= 450 and hitboxX :
  50. print(" HIT ")
  51.  
  52. win.fill((0, 0, 0))
  53.  
  54. enemy()
  55. pygame.draw.rect(win, (250, 0, 0), (30, y, 70, 70))
  56.  
  57. pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment