45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from typing import List, Dict, Tuple
|
|
from garbageCan import GarbageCan
|
|
from speedBump import SpeedBump
|
|
from street import Street
|
|
from gameContext import GameContext
|
|
|
|
|
|
class City:
|
|
cans: List[GarbageCan]
|
|
bumps: List[SpeedBump]
|
|
streets: List[Street]
|
|
cans_dict: Dict[Tuple[int, int], GarbageCan] = {}
|
|
|
|
def __init__(self) -> None:
|
|
self.nodes = []
|
|
self.streets = []
|
|
self.bumps = []
|
|
|
|
def add_can(self, can: GarbageCan) -> None:
|
|
self.nodes.append(can)
|
|
self.cans_dict[can.position] = can
|
|
|
|
def add_street(self, street: Street) -> None:
|
|
self.streets.append(street)
|
|
|
|
def add_bump(self, bump: SpeedBump) -> None:
|
|
self.streets.append(bump)
|
|
|
|
def render_city(self, game_context: GameContext) -> None:
|
|
self._render_streets(game_context)
|
|
self._render_nodes(game_context)
|
|
self._render_bumps(game_context)
|
|
|
|
def _render_streets(self, game_context: GameContext) -> None:
|
|
for street in self.streets:
|
|
street.render(game_context)
|
|
|
|
def _render_nodes(self, game_context: GameContext) -> None:
|
|
for node in self.nodes:
|
|
node.render(game_context)
|
|
|
|
def _render_bumps(self, game_context: GameContext) -> None:
|
|
for bump in self.bumps:
|
|
bump.render(game_context)
|