Compare commits

...

3 Commits

Author SHA1 Message Date
5976f41f12 Merge pull request 'background' (#13) from background into master
Reviewed-on: #13
2023-04-03 15:10:06 +02:00
Pawel Felcyn
e1c7e6d6e7 render grass background 2023-04-03 15:08:26 +02:00
Pawel Felcyn
697a7cdebb add grass background img 2023-04-03 14:58:28 +02:00
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()