From ecab9405415059c68f9163d0ef03b5e9533ec3e8 Mon Sep 17 00:00:00 2001 From: nimeissn Date: Wed, 18 May 2022 19:08:34 +0200 Subject: [PATCH] =?UTF-8?q?Inaktivit=C3=A4ts=20funktion=20und=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VSCode/Pong/src/main.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/VSCode/Pong/src/main.cpp b/VSCode/Pong/src/main.cpp index f6ac0c0..32b9945 100755 --- a/VSCode/Pong/src/main.cpp +++ b/VSCode/Pong/src/main.cpp @@ -88,6 +88,8 @@ void playTone(byte type); void toggleLed(byte x, byte y, byte type); byte getPlayerMovement(byte playerId); void endGame(); +void attentionLight(); + #include @@ -155,6 +157,11 @@ void loop() if (isButtonPressed()) { gameState = GAME_STATE_INIT; } + else if (millis() - lastDrawUpdate > 10000) + { + resetLEDs(); + attentionLight(); + } break; } } @@ -342,13 +349,14 @@ void updateGame() Serial.printf("Punkte Player Red %d\n", pointsPlayerRed); toggleLed(0,10+i,LED_TYPE_POINTS_RED); } - if(pointsPlayerBlue == 5 ) + if(pointsPlayerBlue == 5) { + pointsPlayerBlue = 0; pointsPlayerRed = 0; for (int i =0; i<200; i++) { - pixels.setPixelColor(i, 0,0,255); + pixels.setPixelColor(i, 0,0,55); } } @@ -358,7 +366,7 @@ void updateGame() pointsPlayerRed = 0; for (int i =0; i<200; i++) { - pixels.setPixelColor(i, 255,0,0); + pixels.setPixelColor(i, 55,0,0); } @@ -465,4 +473,16 @@ void playTone(byte type) } break; } -} \ No newline at end of file +} + + +void attentionLight() +{ + int n = random(0,200); + int r = random(0,250); + int g = random(0,250); + int b = random(0,250); + pixels.setPixelColor(n,Color(r,g,b)); + pixels.show(); + delay(1000); +}