asdf

Dependencies:   mbed

Fork of manworm_ticker_tv by Bayley Wang

Revision:
2:1d16e99f334b
Parent:
1:24fd07a24094
Child:
3:d9edc0575aa3
diff -r 24fd07a24094 -r 1d16e99f334b main.cpp
--- a/main.cpp	Sat Nov 18 07:37:42 2017 +0000
+++ b/main.cpp	Sat Nov 18 08:36:25 2017 +0000
@@ -8,7 +8,7 @@
 #define Y_MAX (V_RES/4 - 15)
 
 int SX_MIN = 30;
-int SX_MAX = 90;
+int SX_MAX = 95;
 int SY_MIN = 10;
 int SY_MAX = 50;
 int PADDLE_LEN = 10;
@@ -112,8 +112,10 @@
 float bx = (SX_MIN+SX_MAX)/2, by = (SY_MIN+SY_MAX)/2;
 float bxv = 0.03, byv = 0.03;
 
-DigitalIn p1_in(A0);
-DigitalIn p2_in(A1);
+int s1 = 0, s2 = 0;
+
+DigitalIn p1_in(A1);
+DigitalIn p2_in(A0);
 
 void make_checkerboard()
 {
@@ -439,12 +441,13 @@
     im_line_va[H_RES*(int)by+(int)bx] = 1;
     for(;;)
     {
+        //clear frame
         for(int y = 0; y < PADDLE_LEN; y++) {
             im_line_va[H_RES*(y+(int)p1)+SX_MIN] = 0;
             im_line_va[H_RES*(y+(int)p2)+SX_MAX] = 0;
         }
         im_line_va[H_RES*(int)by+(int)bx] = 0;
-        
+        //read inputs
         int cmd1 = p1_in.read();
         int cmd2 = p2_in.read();
         if (cmd1 == 0) p1v = 0.1; else p1v = -0.1f;
@@ -463,12 +466,18 @@
         if (bx < SX_MIN) {
             bxv = -bxv; 
             bx = SX_MIN;
-            if ((int) by < (int) p1 || (int) by > (int) (p1 + 10)) break;
-        }
+            if (by < p1 || by > p1 + PADDLE_LEN) {
+                im_line_va[H_RES*(SY_MIN-2)+2*s1+SX_MIN] = 1;
+                s1++;
+            }
+        } 
         if (bx > SX_MAX) {
             bxv = -bxv; 
             bx = SX_MAX;
-            if ((int) by < (int) p2 || (int) by > (int) (p2 + 10)) break;
+            if (by < p2 || by > p2 + PADDLE_LEN) {
+                im_line_va[H_RES*(SY_MAX+2)+2*s2+SX_MIN] = 1;
+                s2++;
+            }
         }
         if (by < SY_MIN) {byv = -byv; by = SY_MIN;}
         if (by > SY_MAX) {byv = -byv; by = SY_MAX;}
@@ -479,14 +488,15 @@
         }
         im_line_va[H_RES*(int)by+(int)bx] = 1;
         
-        wait(1/600.0f);
+        wait(1/1200.0f);
     }
     
-p1 = (SY_MIN+SY_MAX)/2-PADDLE_LEN/2, p2 = (SY_MIN+SY_MAX)/2-PADDLE_LEN/2;
- p1v = 0.1, p2v = -0.1;
+    p1 = (SY_MIN+SY_MAX)/2-PADDLE_LEN/2, p2 = (SY_MIN+SY_MAX)/2-PADDLE_LEN/2;
+    p1v = 0.1, p2v = -0.1;
 
- bx = (SX_MIN+SX_MAX)/2, by = (SY_MIN+SY_MAX)/2;
- bxv = 0.03, byv = 0.03;
+    bx = (SX_MIN+SX_MAX)/2, by = (SY_MIN+SY_MAX)/2;
+    bxv = 0.03, byv = 0.03;
+    
     for (;;) 
     {
         for(int i = 0; i < 20000; i++)