From 681719df657d808a54edb03aeaae5f31880d0cef Mon Sep 17 00:00:00 2001 From: s475275 Date: Sun, 26 Mar 2023 20:11:29 +0200 Subject: [PATCH] =?UTF-8?q?=C5=9Amieciarka=20mo=C5=BCe=20wje=C5=BCd=C5=BCa?= =?UTF-8?q?=C4=87=20na=20wysypisko?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/simulation.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/simulation.py b/src/simulation.py index c5003d7..b67e81b 100644 --- a/src/simulation.py +++ b/src/simulation.py @@ -36,7 +36,9 @@ class TruckEntity(Entity): proposed_pos = self.position + move_vector move_valid = True - if proposed_pos not in self.state.roads_pos and proposed_pos not in self.state.houses_pos: + if proposed_pos not in self.state.roads_pos \ + and proposed_pos not in self.state.houses_pos \ + and proposed_pos not in self.state.dumps_pos: move_valid = False if proposed_pos.x < 0 or proposed_pos.x >= self.state.world_limits.x: move_valid = False @@ -63,6 +65,7 @@ class SimulationState: def __init__(self): self.roads_pos = [] self.houses_pos = [] + self.dumps_pos = [] self.entities = [] map_path = Path("../res/map.txt") @@ -83,15 +86,19 @@ class SimulationState: self.houses_pos.append(pg.Vector2(x, y)) self.entities.append(HouseEntity(self, pg.Vector2(x, y))) if tile == "M": + self.dumps_pos.append(pg.Vector2(x, y)) self.paper_dump_pos = pg.Vector2(x, y) self.entities.append(DumpEntity(self, pg.Vector2(x, y), 'paper')) if tile == "P": + self.dumps_pos.append(pg.Vector2(x, y)) self.plastic_dump_pos = pg.Vector2(x, y) self.entities.append(DumpEntity(self, pg.Vector2(x, y), 'plastic')) if tile == "S": + self.dumps_pos.append(pg.Vector2(x, y)) self.glass_dump_pos = pg.Vector2(x, y) self.entities.append(DumpEntity(self, pg.Vector2(x, y), 'glass')) if tile == "Z": + self.dumps_pos.append(pg.Vector2(x, y)) self.mixed_dump_pos = pg.Vector2(x, y) self.entities.append(DumpEntity(self, pg.Vector2(x, y), 'mixed')) self.entities.append(TruckEntity(self, self.truck_origin))