diff --git a/gameContext.py b/gameContext.py new file mode 100644 index 0000000..c20844b --- /dev/null +++ b/gameContext.py @@ -0,0 +1,5 @@ +class GameContext: + dust_car_position_x = 0 + dust_car_position_y = 0 + stick_man_pygame = None + canvas = None \ No newline at end of file diff --git a/gameEventHandler.py b/gameEventHandler.py index 106f1e8..a8aa404 100644 --- a/gameEventHandler.py +++ b/gameEventHandler.py @@ -1,4 +1,9 @@ import pygame +from gameContext import GameContext -def handle_game_event(event): - return \ No newline at end of file +def handle_game_event(event, game_context: GameContext): + update_canvas(game_context) + return + +def update_canvas(game_context: GameContext): + game_context.canvas.blit(game_context.stick_man_pygame, (game_context.dust_car_position_x, game_context.dust_car_position_y)) \ No newline at end of file diff --git a/main.py b/main.py index b6f72a3..62cfd84 100644 --- a/main.py +++ b/main.py @@ -1,11 +1,20 @@ import pygame from gameEventHandler import handle_game_event +from gameContext import GameContext +from PIL import Image pygame.init() canvas = pygame.display.set_mode((800, 800)) pygame.display.set_caption("Inteligentna śmieciarka") +stick_man_pil = Image.open('imgs/sickMan.jpg') + +gameContext = GameContext() +gameContext.stick_man_pygame = pygame.image.frombuffer(stick_man_pil.tobytes(), stick_man_pil.size, 'RGB') +gameContext.canvas = canvas + + exit = False while not exit: @@ -13,6 +22,6 @@ while not exit: if event.type == pygame.QUIT: exit = True else: - handle_game_event(event) + handle_game_event(event, gameContext) pygame.display.update() \ No newline at end of file