1D-Pong game based on a LED strip with 150 LPD6803-controlled pixels. Game keeps score for 'best-of-21' game. Written for KL25Z

Dependencies:   MODSERIAL mbed

Files at this revision

API Documentation at this revision

Comitter:
vsluiter
Date:
Fri Aug 23 08:03:51 2013 +0000
Parent:
14:5b588ea6bd8f
Child:
16:f0176e9e4a9d
Commit message:
Corrected paddle for right position againg. Position NUMBER_OF_PIXELS-1 is where a hit is registered.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Fri Aug 23 07:52:12 2013 +0000
+++ b/main.cpp	Fri Aug 23 08:03:51 2013 +0000
@@ -184,11 +184,11 @@
                 {
                     //printf("\n\rright pushed"); 
                     rightpushed = false;
-                    if(rightpushpos >= NUMBER_OF_PIXELS  )
+                    if(rightpushpos >= NUMBER_OF_PIXELS-1  ) //also count when hit at last pixel = NUMBER_OF_PIXELS-1
                     {
                         paddle.direction = 0;
-                        paddle.setSpeed(25+(-NUMBER_OF_PIXELS+rightpushpos)*4);
-                        paddle.position = NUMBER_OF_PIXELS;
+                        paddle.setSpeed(25+(rightpushpos-(NUMBER_OF_PIXELS-1))*4);
+                        paddle.position = NUMBER_OF_PIXELS-1;
                     }
                     pc.printf("\n\rright pushed. Paddle position: %d, registered: %d", paddle.position, rightpushpos);
                 }
@@ -230,13 +230,13 @@
                 paddle.position = NUMBER_OF_PIXELS;
              }
          }
-         if(gametimer.read()>6 && !naglevel1)
+         if(gametimer.read()>10 && !naglevel1)
         {
             naglevel1 = 1;
             paddle.setSize(4);
             //paddle.setSpeed(40);
         }
-        if(gametimer.read()>10 && !naglevel2)
+        if(gametimer.read()>15 && !naglevel2)
         {
             naglevel2 = 1;
             paddle.setSize(2);