sztuczna_inteligencja_2023_.../city.py

44 lines
1.3 KiB
Python
Raw Normal View History

2023-05-13 23:06:42 +02:00
from typing import List, Dict, Tuple
2023-03-26 21:29:40 +02:00
from garbageCan import GarbageCan
2023-05-13 19:30:00 +02:00
from speedBump import SpeedBump
2023-04-03 15:49:28 +02:00
from street import Street
2023-05-15 08:07:08 +02:00
from gameContext import GameContext
2023-03-26 21:29:40 +02:00
class City:
2023-05-13 23:06:42 +02:00
cans: List[GarbageCan]
2023-05-13 19:30:00 +02:00
bumps: List[SpeedBump]
2023-04-03 15:49:28 +02:00
streets: List[Street]
2023-05-13 23:06:42 +02:00
cans_dict: Dict[Tuple[int, int], GarbageCan] = {}
2023-03-26 21:29:40 +02:00
def __init__(self) -> None:
2023-05-15 10:59:30 +02:00
self.cans = []
2023-03-26 21:29:40 +02:00
self.streets = []
2023-05-13 19:30:00 +02:00
self.bumps = []
2023-03-26 21:29:40 +02:00
2023-05-13 23:06:42 +02:00
def add_can(self, can: GarbageCan) -> None:
2023-05-15 10:59:30 +02:00
self.cans.append(can)
2023-05-13 23:06:42 +02:00
self.cans_dict[can.position] = can
2023-05-15 08:07:08 +02:00
2023-04-03 15:49:28 +02:00
def add_street(self, street: Street) -> None:
self.streets.append(street)
2023-05-15 08:07:08 +02:00
2023-05-13 19:30:00 +02:00
def add_bump(self, bump: SpeedBump) -> None:
self.streets.append(bump)
2023-03-26 21:29:40 +02:00
2023-04-03 15:49:28 +02:00
def render_city(self, game_context: GameContext) -> None:
self._render_streets(game_context)
2023-04-23 15:34:29 +02:00
self._render_nodes(game_context)
2023-05-13 19:30:00 +02:00
self._render_bumps(game_context)
2023-04-03 15:49:28 +02:00
def _render_streets(self, game_context: GameContext) -> None:
for street in self.streets:
2023-04-23 15:34:29 +02:00
street.render(game_context)
2023-05-15 08:07:08 +02:00
2023-04-23 15:34:29 +02:00
def _render_nodes(self, game_context: GameContext) -> None:
2023-05-15 10:59:30 +02:00
for node in self.cans:
2023-05-13 19:30:00 +02:00
node.render(game_context)
2023-05-15 08:07:08 +02:00
2023-05-13 19:30:00 +02:00
def _render_bumps(self, game_context: GameContext) -> None:
for bump in self.bumps:
2023-05-25 18:18:11 +02:00
bump.render(game_context)