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

32
city.py
View File

@ -1,17 +1,19 @@
from typing import List, Tuple
from typing import List
from garbageCan import GarbageCan
from street import Street
from gameContext import GameContext
class Node:
garbageCan: GarbageCan
id: int
def __init__(self, id: int, can: GarbageCan) -> None:
self.id = id
self.id
self.can = can
class City:
nodes: List[Node]
streets: List[Tuple[int, int]]
streets: List[Street]
def __init__(self) -> None:
self.nodes = []
@ -20,20 +22,12 @@ class City:
def add_node(self, node: Node) -> None:
self.nodes.append(node)
def add_street(self, street: Tuple[int, int]) -> None:
firstFound: bool = False
secondFound: bool = False
def add_street(self, street: Street) -> None:
self.streets.append(street)
for node in self.nodes:
if firstFound and secondFound:
break
if node.id == street.__getitem__(0):
firstFound = True
continue
if node.id == street.__getitem__(1):
secondFound = True
if not firstFound or not secondFound:
return
self.streets.append(street)
def render_city(self, game_context: GameContext) -> None:
self._render_streets(game_context)
def _render_streets(self, game_context: GameContext) -> None:
for street in self.streets:
street.render(game_context)