Asteroids for MBED game with Bluetooth LE UART Friend Controller, uLCD, speaker, and uSD.

Dependencies:   4DGL-uLCD-SE mbed-rtos mbed

Asteroids for MBED game with Bluetooth LE UART Friend Controller

Revision:
10:6bb7504e0f5a
Parent:
9:49f4b9dcab22
Child:
11:d707cebe6eff
--- a/main.cpp	Sat Mar 12 20:57:33 2016 +0000
+++ b/main.cpp	Sat Mar 12 21:11:19 2016 +0000
@@ -21,6 +21,7 @@
 BusOut myled(LED1,LED2,LED3,LED4);
 Serial blue(p13,p14);
 SongPlayer myspkr(p26);
+Mutex stdio_mutex;
 
 //Globals
 int game_speed = 25;
@@ -31,7 +32,7 @@
 bool four = 0;
 bool colsound = 0;
 int lives = 3;
-int round = 1;
+int round = 0;
 
 class Movement
 {
@@ -132,6 +133,7 @@
 
 void controls(void const *args)
 {
+    stdio_mutex.lock();
     char bnum=0;
     char bhit=0;
     while(1) {
@@ -206,6 +208,7 @@
             }
         }
     }
+    stdio_mutex.unlock();
 }
 
 void move(Movement &p)
@@ -223,12 +226,14 @@
 //game_over
 void game_over()
 {
+    stdio_mutex.lock();
     ulcd.cls();
     ulcd.printf("GAME OVER");
     wait(3);
     ulcd.cls();
     lives = 3;
     ulcd.printf("%d",lives);
+    stdio_mutex.unlock();
 
 }
 //move
@@ -353,7 +358,7 @@
 void round_check(list<Movement> &asteroids){
     if(asteroids.empty()){
         round++;
-        for(int i = 0; i < round; i++){
+        for(int i = 0; i < round && i < 4; i++){
             new_asteroid(asteroids, 140*(i%2), 140*((i%2)+1),10);
         }
     }
@@ -368,10 +373,10 @@
     ulcd.baudrate(BAUD_3000000);
     Thread sound(crash);
     Thread buttons(controls);
-    Movement player(50, 100, 0, -5, 0, 10, 1);
+    Movement player(70,70,0,0,0,10,1);
     list<Movement> asteroids;
     list<Movement> bullets;
-    Movement p_player(50, 100, 0, -5, 0, 10, 1);
+    Movement p_player(70,70,0,0,0,10,1);
     list<Movement> p_asteroids;
     list<Movement> p_bullets;
     while(1) {