diff --git a/gameContext.py b/gameContext.py index a59e292..592a491 100644 --- a/gameContext.py +++ b/gameContext.py @@ -1,4 +1,5 @@ import pygame +from PIL import Image class GameContext: dust_car_speed = 20 @@ -9,4 +10,10 @@ class GameContext: canvas = None def startup(game_context: GameContext): + render_background(game_context) game_context.canvas.blit(game_context.dust_car_pygame, (game_context.dust_car_position_x, game_context.dust_car_position_y)) + +def render_background(game_context: GameContext): + bg_img = Image.open("imgs/background.jpg") + pygame_bg_image = pygame.image.frombuffer(bg_img.tobytes(), bg_img.size, 'RGB') + game_context.canvas.blit(pygame_bg_image, (0, 0)) diff --git a/imgs/backgroud.jpg b/imgs/background.jpg similarity index 100% rename from imgs/backgroud.jpg rename to imgs/background.jpg diff --git a/main.py b/main.py index 0084bd5..644de16 100644 --- a/main.py +++ b/main.py @@ -26,5 +26,4 @@ while not exit: exit = True else: handle_game_event(event, game_context) - pygame.display.update() \ No newline at end of file