Advertisement
stilian1231231

Untitled

Jul 28th, 2022
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. import pygame
  2.  
  3. GAME_WIDTH = 1920
  4. GAME_HEIGHT = 1080
  5.  
  6. pygame.init()
  7. window = pygame.display.set_mode((GAME_WIDTH,GAME_HEIGHT))
  8. FPS = pygame.time.Clock()
  9. pygame.display.set_caption("My game")
  10.  
  11. x = 120
  12. y = 820
  13. vel_y = 20
  14. vel = 20
  15. a = False
  16. jump = False
  17. color = "Yellow"
  18. second_level = False
  19. square_width = 100
  20. square_place_y = 700
  21.  
  22. while True:
  23.     for event in pygame.event.get():
  24.         if event.type == pygame.QUIT:
  25.             pygame.quit()
  26.     window.fill("Black")
  27.  
  28.     cyrcle = pygame.draw.circle(window,("White"),(int(x),int(y)),30)
  29.     earth = pygame.draw.rect(window,(color),[0,850,2100,30])
  30.  
  31.  
  32.     if jump is False and pygame.key.get_pressed()[pygame.K_SPACE]:
  33.         jump = True
  34.  
  35.     if jump is True:
  36.         y -= vel_y
  37.         vel_y -= 1
  38.         if vel_y < -20:
  39.             jump = False
  40.             vel_y = 20
  41.  
  42.     if pygame.key.get_pressed()[pygame.K_RIGHT]:
  43.         b = True
  44.         if b is True:
  45.             x += 8
  46.  
  47.  
  48.     if pygame.key.get_pressed()[pygame.K_LEFT]:
  49.         x -= 8
  50.  
  51.  
  52.     if x > 1920:
  53.         second_level = True
  54.         color = "Blue"
  55.         x = 10
  56.  
  57.     if second_level is True:
  58.         coin = pygame.draw.ellipse (window, ("Yellow"), [700, 400, 30, 60], 5)
  59.         platform = pygame.draw.rect (window, ("Red"), [600, 500, 300, 100], 5)
  60.         platform2 = pygame.draw.rect (window, ("Red"), [1200, square_place_y, square_width, 100], 5)
  61.        # print(vel_y,cyrcle.x)
  62.  
  63.  
  64.  
  65.  
  66.  
  67.     FPS.tick(80)
  68.     pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement