IRESTE/CarController.py
2022-02-10 15:54:44 +01:00

24 lines
629 B
Python

import sumolib
from Car import Car
class CarController:
def __init__(self,path,parentMap,surface):
self.map=parentMap
self.surf=surface
self.cars=[]
self.fromPath(path)
def fromPath(self,path):
for vehicle in sumolib.xml.parse(path,"vehicle"):
route=vehicle.route[0].edges.split()
self.cars.append(Car(vehicle.id,route,self.map,self.surf))
def update(self):
for car in self.cars:
car.update(1.0/60)
def draw(self,screen):
for car in self.cars:
car.draw((255,255,255))
screen.blit(self.surf,(0,0))