movement #3

Merged
s473616 merged 4 commits from movement into master 2023-03-12 16:51:41 +01:00
3 changed files with 22 additions and 3 deletions
Showing only changes of commit 9f7bc7f3e1 - Show all commits

5
gameContext.py Normal file
View File

@ -0,0 +1,5 @@
class GameContext:
dust_car_position_x = 0
dust_car_position_y = 0
stick_man_pygame = None
canvas = None

View File

@ -1,4 +1,9 @@
import pygame
from gameContext import GameContext
def handle_game_event(event):
return
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))

11
main.py
View File

@ -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()