FIX: Pong timing

This commit is contained in:
Patrick Haßel 2023-01-09 10:18:27 +01:00
parent 1d0c3c0c1c
commit 8a7ddb006c

View File

@ -43,6 +43,7 @@ public:
protected: protected:
void tick(uint8_t index, milliseconds_t milliseconds) override { void tick(uint8_t index, milliseconds_t milliseconds) override {
Serial.printf("tick(%lu)\n", milliseconds);
switch (status) { switch (status) {
case SCORE: case SCORE:
timeout -= milliseconds; timeout -= milliseconds;
@ -57,8 +58,6 @@ protected:
paddleBounce(); paddleBounce();
checkScoring(); checkScoring();
topBottomBounce(); topBottomBounce();
// TODO don't always markDirty. Be more efficient
markDirty(); markDirty();
break; break;
@ -66,8 +65,8 @@ protected:
timeout -= milliseconds; timeout -= milliseconds;
if (timeout <= 0) { if (timeout <= 0) {
resetPlayer(); resetPlayer();
status = SCORE; status = PLAY;
timeout = 2000000; timeout = 0;
} }
break; break;
} }
@ -126,7 +125,7 @@ private:
} }
if (player0.score >= 10 || player1.score >= 10) { if (player0.score >= 10 || player1.score >= 10) {
status = OVER; status = OVER;
timeout = 2000000; timeout = 2000;
} }
} }
@ -146,7 +145,7 @@ private:
velocity.x = direction; velocity.x = direction;
velocity.y = 0; velocity.y = 0;
status = SCORE; status = SCORE;
timeout = 2000000; timeout = 2000;
} }
}; };