streets_rendering #14

Merged
s473616 merged 6 commits from streets_rendering into master 2023-04-03 19:52:09 +02:00
Showing only changes of commit 9f0cdbc5ff - Show all commits

View File

@ -1,3 +1,4 @@
from typing import Tuple
import pygame
from PIL import Image
@ -8,6 +9,14 @@ class GameContext:
dust_car_pygame = None
dust_car_pil = None
canvas = None
_cell_size: int = 30
def render_in_cell(self, cell: Tuple[int, int], img_path: str):
img = Image.open(img_path)
pygame_img = pygame.image.frombuffer(img.tobytes(), (self._cell_size,self._cell_size), 'RGB')
start_x = (cell[0] - 1) * self._cell_size
start_y = (cell[1] - 1) * self._cell_size
self.canvas.blit(pygame_img, (start_x, start_y))
def startup(game_context: GameContext):
render_background(game_context)