diff --git a/imgs/a.jpg b/imgs/a.jpg new file mode 100644 index 0000000..8871b54 Binary files /dev/null and b/imgs/a.jpg differ diff --git a/imgs/house.png b/imgs/house.jpg similarity index 100% rename from imgs/house.png rename to imgs/house.jpg diff --git a/main.py b/main.py index b6f72a3..74f4380 100644 --- a/main.py +++ b/main.py @@ -1,18 +1,45 @@ -import pygame from gameEventHandler import handle_game_event +import pygame +from PIL import Image + + pygame.init() +window_size = (800, 600) +screen = pygame.display.set_mode(window_size) -canvas = pygame.display.set_mode((800, 800)) +# wczytanie mapy i ludzika (jezeli chcemy robic to bez przeksztłcania pilem i uzyc samego pygame to trzeba miec img w tym samym +# folderze co gra) +mapa_pil = Image.open('imgs/house.jpg') +mapa_pygame = pygame.image.frombuffer(mapa_pil.tobytes(), mapa_pil.size, 'RGB') +ludzik_pil = Image.open('imgs/a.jpg') +ludzik_pygame = pygame.image.frombuffer(ludzik_pil.tobytes(), ludzik_pil.size, 'RGB') -pygame.display.set_caption("Inteligentna śmieciarka") -exit = False +# pozycja ludzika +ludzik_x = 0 +ludzik_y = 0 -while not exit: +# główna pętla gry +while True: for event in pygame.event.get(): if event.type == pygame.QUIT: - exit = True - else: - handle_game_event(event) + pygame.quit() + quit() + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT: + ludzik_x -= 10 + elif event.key == pygame.K_RIGHT: + ludzik_x += 10 + elif event.key == pygame.K_UP: + ludzik_y -= 10 + elif event.key == pygame.K_DOWN: + ludzik_y += 10 - pygame.display.update() \ No newline at end of file + screen.fill((255, 255, 255)) + + # wyświetlenie mapy i ludzika + screen.blit(mapa_pygame, (0, 0)) + screen.blit(ludzik_pygame, (ludzik_x, ludzik_y)) + + # odświeżenie ekranu + pygame.display.update() diff --git a/tes.py b/tes.py deleted file mode 100644 index e69de29..0000000