|
@@ -18,7 +18,7 @@ class Controller
|
18
|
18
|
this.#drawer.computeGameParams(params.TUBESNUMBERS, params.TUBESLEVELS);
|
19
|
19
|
|
20
|
20
|
this.ui = new UI(800, 600);
|
21
|
|
- this.lastTime = 0;
|
|
21
|
+ this.lastTime = millis();
|
22
|
22
|
|
23
|
23
|
this.initializeColorTubes(params.TUBESLEVELS - 1);
|
24
|
24
|
|
|
@@ -126,15 +126,15 @@ class Controller
|
126
|
126
|
|
127
|
127
|
runLoop()
|
128
|
128
|
{
|
129
|
|
- const timeDelta = millis() - this.lastTime;
|
|
129
|
+ let timeDelta = millis() - this.lastTime;
|
130
|
130
|
// peut-être pas nécessaire de limiter le framerate
|
131
|
|
- if (timeDelta < 50)
|
|
131
|
+ if (timeDelta < 1000 / 60)
|
132
|
132
|
return;
|
133
|
133
|
this.lastTime = millis();
|
134
|
134
|
|
135
|
135
|
const steps = [
|
136
|
136
|
(this.needUpdate || this.#game.isCompleted) && this.drawGame,
|
137
|
|
- this.#game.isCompleted && this.drawUI
|
|
137
|
+ this.#game.isComplete() && this.drawUI
|
138
|
138
|
]
|
139
|
139
|
|
140
|
140
|
steps.forEach(step => step && step.call(this));
|