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 ba49049cc3 - Show all commits

25
street.py Normal file
View File

@ -0,0 +1,25 @@
from enum import Enum
from typing import Tuple
from gameContext import GameContext
class StreetType (Enum):
VERTICAL = 0
HORIZONTAL = 0
class Street:
street_type: StreetType
start_cell: int
end_cell: int
row_or_column: int
def __init__(self, start_cell: int, end_cell: int, row_or_column: int, street_type: StreetType = StreetType.VERTICAL) -> None:
self.start_cell = start_cell
self.end_cell = end_cell
self.street_type = street_type
self.row_or_column = row_or_column
def render(self, game_context: GameContext) -> None:
for i in range(self.start_cell, self.end_cell):
img_str: str = 'imgs/street_vertical.png' if self.street_type == StreetType.VERTICAL else 'imgs/street_horizontal.png'
cell: Tuple[int, int] = (i, self.row_or_column) if self.street_type == StreetType.VERTICAL else (self.row_or_column, i)
game_context.render_in_cell(cell, img_str)