Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame # importu biblioteki/modułu pygame
- pygame.init() # inicjalizacja pygame'a
- # ustalenie rozmiaru okna
- SCREEN_WIDTH = 800
- SCREEN_HEIGHT = 600
- # utworzenie okna
- # i ustalenie wymiarów okienka
- screen_surface = pygame.display.set_mode( (SCREEN_WIDTH, SCREEN_HEIGHT) )
- # nadawanie nazwy oknu
- pygame.display.set_caption('Pierwsza gra w Pygame')
- clock = pygame.time.Clock()
- def load_image(img_path: str, position):
- image = pygame.image.load(img_path)
- surface = image.convert()
- transparent_color = (0,0,0)
- surface.set_colorkey(transparent_color)
- rect = surface.get_rect(center=position)
- return [image, surface, rect]
- def print_image(img_list):
- #image = list[0]
- #surface = list[1]
- #rect = list[2]
- image, surface, rect = img_list
- screen_surface.blit(surface, rect)
- pass
- def set_image_position(img_list, position):
- image, surface, rect = img_list
- rect = surface.get_rect(center=position)
- return [image, surface, rect]
- ###### ZMIENNE GRY #############
- player_pos = [SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2]
- player = load_image('player.png', player_pos)
- ###### koniec zmiennych gry ####
- game_running = True
- while game_running:
- # główna pętla programu
- events = pygame.event.get() # zapisanie wszystkich zdarzeń do listy events
- for event in events:
- print(event)
- if event.type == pygame.QUIT:
- game_running = False
- pass
- pass
- pressed_keys = pygame.key.get_pressed()
- if(pressed_keys[pygame.K_ESCAPE]):
- game_running = False
- print_image(player)
- pygame.display.update() # odświeżenie okna
- clock.tick(60)
- pass
- pygame.quit() # zapytaknie aplikacji pygame
- quit() # zamknięcie skryptu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement