From c0890287fdcc008c4e9ad6f566959645a9d9a570 Mon Sep 17 00:00:00 2001 From: leo Date: Fri, 11 Mar 2022 15:20:06 +0100 Subject: [PATCH] fix --- Car.py | 11 +-- CarController.py | 5 ++ main.py | 3 +- mainLoop.py | 2 + test6.net.xml | 190 +++++++++++++++++++++++++++++++++++++++++++++++ test9.rou.xml | 43 +++++++++++ window.py | 4 +- window.ui | 4 +- 8 files changed, 252 insertions(+), 10 deletions(-) create mode 100644 test6.net.xml create mode 100644 test9.rou.xml diff --git a/Car.py b/Car.py index 86bc533..38934f7 100644 --- a/Car.py +++ b/Car.py @@ -163,10 +163,10 @@ class Car(): #painter.drawEllipse(pt,100,100) def conduite(self,vmax,leader,dt): - if self.id == "f_00" and self.controller.t%10>5: - - self.v = 0 - return + #if self.id == "f_00" and self.controller.t%10>5: + # + # self.v = 0 + # return if(leader is None): self.v = self.vmax @@ -226,6 +226,7 @@ class Car(): self.index+=1 if(self.index>=len(self.route)-1): self.index=0 + self.controller.destroyCar(self) self.initPath() self.pos=list(self.laneShape[self.laneInd]) @@ -235,7 +236,7 @@ class Car(): self.pos[1]+=(endPos[1]-self.pos[1])*adv lgt=0 - if randint(0,100) == 0: + if self.controller.vroomEnable and randint(0,100) == 0: self.vroom = 60 if self.infoWidg is None: diff --git a/CarController.py b/CarController.py index c9c8ecc..1cd09ea 100644 --- a/CarController.py +++ b/CarController.py @@ -102,6 +102,8 @@ class CarController: self.t=0 self.infoWidget=mainWindow.findChild(QToolBox, "carInfos") + self.vroomEnable=True + varWidget = mainWindow.ui.constEdit varWidget.addWidget(varEdit(varWidget, self, "gamma", 5)) varWidget.addWidget(varEdit(varWidget, self, "delta", 0.5)) @@ -159,6 +161,9 @@ class CarController: painter.setPen(Qt.white) car.draw(painter) + def destroyCar(self, car): + self.cars.remove(car) + def updateConstant(self, name, val): for car in self.cars: car.__dict__[name] = val diff --git a/main.py b/main.py index dbf3a24..8508a2a 100644 --- a/main.py +++ b/main.py @@ -61,7 +61,8 @@ class MainWindow(QMainWindow): def keyPressEvent(self, e): if e.key() == Qt.Key_Escape or e.key() == Qt.Key_Q: self.close() - + elif e.key() == Qt.Key_V: + self.mainLoop.controller.vroomEnable = not self.mainLoop.controller.vroomEnable elif e.key() == Qt.Key_S: self.mainLoop.quickLoad() diff --git a/mainLoop.py b/mainLoop.py index a933ed1..890be5e 100644 --- a/mainLoop.py +++ b/mainLoop.py @@ -1,3 +1,5 @@ +import sys + from Map import Map from CarController import CarController diff --git a/test6.net.xml b/test6.net.xml new file mode 100644 index 0000000..2f47b9e --- /dev/null +++ b/test6.net.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test9.rou.xml b/test9.rou.xml new file mode 100644 index 0000000..664639a --- /dev/null +++ b/test9.rou.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/window.py b/window.py index 843d99b..f3d8a0b 100644 --- a/window.py +++ b/window.py @@ -65,7 +65,7 @@ class Ui_MainWindow(object): self.mainFPS_set = QSpinBox(self.centralwidget) self.mainFPS_set.setObjectName(u"mainFPS_set") self.mainFPS_set.setMaximum(500) - self.mainFPS_set.setValue(60) + self.mainFPS_set.setValue(17) self.horizontalLayout_3.addWidget(self.mainFPS_set) @@ -84,7 +84,7 @@ class Ui_MainWindow(object): self.physicsFPS_set = QSpinBox(self.centralwidget) self.physicsFPS_set.setObjectName(u"physicsFPS_set") self.physicsFPS_set.setMaximum(1000) - self.physicsFPS_set.setValue(60) + self.physicsFPS_set.setValue(17) self.horizontalLayout_4.addWidget(self.physicsFPS_set) diff --git a/window.ui b/window.ui index 95cc3df..1fb2716 100644 --- a/window.ui +++ b/window.ui @@ -58,7 +58,7 @@ 500 - 60 + 17 @@ -79,7 +79,7 @@ 1000 - 60 + 17