Advertisement
gandalfbialy

Untitled

May 26th, 2025
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import pygame
  2.  
  3. def load_image(img_path: str, position):
  4.     image = pygame.image.load(img_path)
  5.     surface = image.convert()
  6.  
  7.     transparent_color = (0, 0, 0)
  8.     surface.set_colorkey(transparent_color)
  9.  
  10.     rect = surface.get_rect(center=position)
  11.  
  12.     return [image, surface, rect]
  13.  
  14. pygame.init()
  15.  
  16. SCREEN_WIDTH = 800
  17. SCREEN_HEIGHT = 600
  18.  
  19. player_pos = [SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2]
  20. player = load_image('player.png', player_pos)
  21.  
  22. screen_surface = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
  23. pygame.display.set_caption("Pierwsza aplikacja w pygame!!!")
  24. clock = pygame.time.Clock()
  25.  
  26. game_status = True
  27.  
  28. while game_status:
  29.     events = pygame.event.get()
  30.  
  31.     for event in events:
  32.         # print(event)
  33.         if event.type == pygame.QUIT:
  34.             game_status = False
  35.  
  36.     pygame.display.update()
  37.     clock.tick(60)
  38.  
  39. pygame.quit()
  40. quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement