streets_rendering #14
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user