Merge pull request 'background' (#13) from background into master

Reviewed-on: #13
This commit is contained in:
Paweł Felcyn 2023-04-03 15:10:06 +02:00
commit 5976f41f12
3 changed files with 7 additions and 1 deletions

View File

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

BIN
imgs/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

View File

@ -26,5 +26,4 @@ while not exit:
exit = True
else:
handle_game_event(event, game_context)
pygame.display.update()