Inteligentna_smieciarka/garbage_truck.py

36 lines
1.1 KiB
Python
Raw Normal View History

2023-04-21 14:31:17 +02:00
FIELDWIDTH = 50
2023-03-31 13:49:27 +02:00
class GarbageTank:
def __init__(self, volume_capacity, mass_capacity):
self.vcapacity = volume_capacity #m^3
self.mcapacity = mass_capacity #kg
class Engine:
def __init__(self, power):
self.power = power #HP
2023-03-31 13:49:27 +02:00
class GarbageTruck:
2023-04-21 14:31:17 +02:00
def __init__(self, dump_location, fuel_capacity, rect, orientation):
self.dump_location = dump_location
2023-03-31 13:49:27 +02:00
self.tank = GarbageTank(15, 18000)
self.engine = Engine(400)
self.fuel = fuel_capacity
2023-04-21 14:31:17 +02:00
self.rect = rect
self.orientation = orientation
2023-04-21 14:31:17 +02:00
self.houses = [] #lista domów do odwiedzenia
def turn_left(self):
self.orientation = (self.orientation - 1) % 4
def turn_right(self):
self.orientation = (self.orientation + 1) % 4
def forward(self):
if self.orientation == 0:
self.rect.x += FIELDWIDTH
elif self.orientation == 1:
self.rect.y += FIELDWIDTH
elif self.orientation == 2:
self.rect.x -= FIELDWIDTH
else:
self.rect.y -= FIELDWIDTH