Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
 - 12:b69657862610
 - Parent:
 - 11:2cd6341136ca
 - Child:
 - 13:f4de03202477
 
--- a/main.cpp	Sun Mar 24 12:31:38 2019 +0000
+++ b/main.cpp	Sun Mar 24 16:59:48 2019 +0000
@@ -18,7 +18,6 @@
 #include "Cube.h"
 #include "Gamepad.h"
 
-Serial pc(USBTX, USBRX); // tx, rx
 Ticker ticker;
 Gamepad gamepad;
 std::vector<Cube> cubeVector;
@@ -27,17 +26,18 @@
 
 int main()
 {
-    
+    int score = 0;
     gamepad.init();
     Rasturizer renderer;
-    for(int i = 0; i < 10; i++){
+    for(int i = 0; i < 2; i++){
         Cube cube(rand()%80-40,0,30+ i*20,5);
         cubeVector.push_back(cube);
     }
     while(1) {
+        score++;
+        Vector2D coord = gamepad.get_coord();
         renderer.clear();
-        renderer.drawHorizon(coord.x/10);
-        Vector2D coord = gamepad.get_coord();
+        renderer.drawHorizon(coord.x/15);
         bool rotate1 = false;
         if(gamepad.check_event(Gamepad::B_PRESSED) == true){
             rotate1 = true;
@@ -58,15 +58,15 @@
             for (int i = 0; i < 6; i++){
                 faceVector.push_back(cubeVector[c].getFace(i));
             }
-            cubeVector[c].translate(-coord.x*2,0,-4);
+            cubeVector[c].translate(-coord.x*2,0,coord.y*2);
 
             if (cubeVector[c].despawn()){
                 cubeVector.erase(cubeVector.begin() + c);
-                Cube cube(rand()%80-40,0,90,5);
+                Cube cube(rand()%160-80,0,90,5);
                 cubeVector.push_back(cube);
             }
             if (cubeVector[c].tooClose()){
-                renderer.print("dead");
+                score = 0;
             }
         }
       
@@ -84,13 +84,18 @@
         
         for (int f = 0; f< faceVector.size() ; f++){
             //pc.printf("%f\n", faceVector[f].getAvgZ());
-            renderer.drawFace(faceVector[f], coord.x/10);
-            
+            renderer.drawFace(faceVector[f], coord.x/15);
+            //wait_ms(1000/1);
+           
         }
+        //char buf[10];
+        //sprintf(buf, "%d", score);
+        //renderer.print(buf);
+        renderer.refresh();
         faceVector.clear();  
          // refresh the LCD so the pixels appear
          // this gives a refresh rate of 10 frames per second
-         renderer.refresh();
+         
         wait_ms(1000/30);
     }
 }