dodany A* - coś jeszcze nie działa

This commit is contained in:
majkellll 2023-05-15 08:07:08 +02:00
parent 311a2d0757
commit af32df4474
2 changed files with 14 additions and 8 deletions

15
city.py
View File

@ -2,8 +2,9 @@ from typing import List, Dict, Tuple
from garbageCan import GarbageCan from garbageCan import GarbageCan
from speedBump import SpeedBump from speedBump import SpeedBump
from street import Street from street import Street
from gameContext import GameContext from gameContext import GameContext
class City: class City:
cans: List[GarbageCan] cans: List[GarbageCan]
bumps: List[SpeedBump] bumps: List[SpeedBump]
@ -18,10 +19,10 @@ class City:
def add_can(self, can: GarbageCan) -> None: def add_can(self, can: GarbageCan) -> None:
self.cans.append(can) self.cans.append(can)
self.cans_dict[can.position] = can self.cans_dict[can.position] = can
def add_street(self, street: Street) -> None: def add_street(self, street: Street) -> None:
self.streets.append(street) self.streets.append(street)
def add_bump(self, bump: SpeedBump) -> None: def add_bump(self, bump: SpeedBump) -> None:
self.streets.append(bump) self.streets.append(bump)
@ -33,11 +34,11 @@ class City:
def _render_streets(self, game_context: GameContext) -> None: def _render_streets(self, game_context: GameContext) -> None:
for street in self.streets: for street in self.streets:
street.render(game_context) street.render(game_context)
def _render_nodes(self, game_context: GameContext) -> None: def _render_nodes(self, game_context: GameContext) -> None:
for node in self.cans: for node in self.cans:
node.render(game_context) node.render(game_context)
def _render_bumps(self, game_context: GameContext) -> None: def _render_bumps(self, game_context: GameContext) -> None:
for bump in self.bumps: for bump in self.bumps:
bump.render(game_context) bump.render(game_context)

View File

@ -1,4 +1,6 @@
import pygame import pygame
from city import City
from gameEventHandler import handle_game_event from gameEventHandler import handle_game_event
from gameContext import GameContext from gameContext import GameContext
from startup import startup from startup import startup
@ -17,8 +19,11 @@ game_context = GameContext()
game_context.dust_car_pil = dust_car_pil game_context.dust_car_pil = dust_car_pil
game_context.dust_car_pygame = pygame.image.frombuffer(dust_car_pil.tobytes(), dust_car_pil.size, 'RGB') game_context.dust_car_pygame = pygame.image.frombuffer(dust_car_pil.tobytes(), dust_car_pil.size, 'RGB')
game_context.canvas = canvas game_context.canvas = canvas
city = City()
startup(game_context) startup(game_context)
collect_garbage(game_context) collect_garbage(game_context, city)
exit = False exit = False