27 lines
818 B
Python
27 lines
818 B
Python
# Code pour gerer le reseau (la carte)
|
|
# Pour l'instant c'est juste un wrapper autour de sumolib
|
|
# mais si on se decide à utiliser notre propre format dans le futur ça faciliterat la transition
|
|
|
|
import sumolib
|
|
import pygame as pg
|
|
|
|
class Map:
|
|
def __init__(self,path : str,surface : pg.Surface):
|
|
self.fromPath(path)
|
|
self.surf=surface
|
|
|
|
def fromPath(self,path : str):
|
|
self.net = sumolib.net.readNet(path,withInternal=True)
|
|
|
|
def draw(self,screen):
|
|
for edge in self.net.getEdges():
|
|
color=(255,255,255)
|
|
if(edge.getFunction()=="internal"):
|
|
color=(255,0,0)
|
|
for lane in edge.getLanes():
|
|
lastPos = None
|
|
pg.draw.lines(self.surf,color,False,lane.getShape())
|
|
|
|
screen.blit(self.surf,(0,0))
|
|
|