pourcentage de ralentissement
This commit is contained in:
parent
578c433f99
commit
8a6368c50a
5
Car.py
5
Car.py
@ -58,6 +58,8 @@ class Car():
|
||||
self.leaderBefore=False
|
||||
self.distToInter=0
|
||||
self.timeStopped=0
|
||||
self.speedPercentage=0
|
||||
self.ticksLived=0
|
||||
|
||||
self.vmax=0
|
||||
|
||||
@ -422,6 +424,9 @@ class Car():
|
||||
if self.v == 0:
|
||||
self.timeStopped += dt
|
||||
|
||||
self.speedPercentage += self.v/self.vmax
|
||||
self.ticksLived += 1
|
||||
|
||||
lgt=self.v*dt
|
||||
|
||||
self.dir = atan2(self.laneShape[self.laneInd+1][1]-self.pos[1],self.laneShape[self.laneInd+1][0]-self.pos[0])
|
||||
|
@ -104,6 +104,7 @@ class CarController:
|
||||
self.spawnFailed = 0
|
||||
self.totalStopped = 0
|
||||
self.carsDestroyed = 0
|
||||
self.speedPercentageTotal = 0
|
||||
|
||||
self.infoWidget = None
|
||||
|
||||
@ -178,7 +179,7 @@ class CarController:
|
||||
self.spawnFailed += 1
|
||||
#flow.addCar2Counter()
|
||||
flow.priority += 1
|
||||
print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
||||
#print(f"nope, y as déjà une voiture ici : n°{self.spawnFailed}")
|
||||
|
||||
def draw(self,painter):
|
||||
for ind,car in enumerate(self.cars):
|
||||
@ -195,6 +196,7 @@ class CarController:
|
||||
def destroyCar(self, car):
|
||||
self.carsDestroyed += 1
|
||||
self.totalStopped += car.timeStopped
|
||||
self.speedPercentageTotal += car.speedPercentage / car.ticksLived
|
||||
self.cars.remove(car)
|
||||
|
||||
def updateConstant(self, name, val):
|
||||
|
3
main.py
3
main.py
@ -83,7 +83,8 @@ class MainWindow(QMainWindow):
|
||||
if controller.carsDestroyed==0:
|
||||
return
|
||||
averageTimeStopped = controller.totalStopped / controller.carsDestroyed
|
||||
widget.setText(f"temps d'arrêt : {averageTimeStopped:.2f}s/voiture \n nombre de voitures qui n'ont pas pu apparaitre : {controller.spawnFailed}")
|
||||
speedPercentage = controller.speedPercentageTotal / controller.carsDestroyed
|
||||
widget.setText(f"temps d'arrêt : {averageTimeStopped:.2f}s/voiture \n nombre de voitures qui n'ont pas pu apparaitre : {controller.spawnFailed} \n <vitesse/vitesse max>T : {speedPercentage:.2f}")
|
||||
|
||||
@Slot(int)
|
||||
def updatePhysicsFps(self,t):
|
||||
|
Loading…
x
Reference in New Issue
Block a user