Advertisement
ada1711

Untitled

Mar 15th, 2023
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import pygame
  2.  
  3. from Platform import Platform
  4.  
  5. # height and width of the screen
  6. SCREEN_WIDTH = 1024
  7. SCREEN_HEIGHT = 800
  8. # pygame settings
  9. pygame.init()
  10.  
  11. # display, clock and background objects
  12. display = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT])
  13. clock = pygame.time.Clock()
  14. background_image = pygame.image.load('images/background.png')
  15.  
  16. # platform object
  17. platform = Platform()
  18.  
  19. # main game loop
  20. game_on = True
  21. while game_on:
  22. for event in pygame.event.get():
  23. if event.type == pygame.KEYDOWN:
  24. if event.key == pygame.K_ESCAPE:
  25. game_on = False
  26. elif event.type == pygame.QUIT:
  27. game_on = False
  28.  
  29. # platform controls
  30. pressed_keys = pygame.key.get_pressed()
  31. if pressed_keys[pygame.K_a]:
  32. platform.move_platform(-1)
  33. if pressed_keys[pygame.K_d]:
  34. platform.move_platform(1)
  35.  
  36. # display background
  37. display.blit(background_image, (0, 0))
  38.  
  39. # display platform
  40. display.blit(platform.image, platform.position)
  41.  
  42. pygame.display.flip()
  43. clock.tick(30)
  44.  
  45. pygame.quit()
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement