![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Updated Space Invaders on the mbed. Improved upon Michael Son's "Mbed Space Invaders" at https://os.mbed.com/users/michaeljson/notebook/mbed-space-invaders/.
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE SparkfunAnalogJoystick SDFileSystem LSM9DS1_Library_cal_updated
Fork of Two-PlayerSpaceInvaders by
test
Diff: main.cpp
- Revision:
- 27:9a17cf897bf8
- Parent:
- 26:3270c6edd7d9
diff -r 3270c6edd7d9 -r 9a17cf897bf8 main.cpp --- a/main.cpp Wed Apr 28 03:12:39 2021 +0000 +++ b/main.cpp Wed Apr 28 14:44:14 2021 +0000 @@ -157,52 +157,52 @@ unsigned int start_enemy_y_pos = 20; numOfEnemies = 15; - // First Row of Enemies - enemy_init(&enemy_1,start_x_pos,start_enemy_y_pos,WHITE); // initialize x-pos and y-pos and color of enemy + // First Row of Enemies + enemy_init(&enemy_1,start_x_pos,start_enemy_y_pos,RED); // initialize x-pos and y-pos and color of enemy_show(&enemy_1); // displays the enemy on uLCD - enemy_init(&enemy_2,start_x_pos+15,start_enemy_y_pos,WHITE); + enemy_init(&enemy_2,start_x_pos+15,start_enemy_y_pos,RED); enemy_show(&enemy_2); - enemy_init(&enemy_3,start_x_pos+30,start_enemy_y_pos,WHITE); + enemy_init(&enemy_3,start_x_pos+30,start_enemy_y_pos,RED); enemy_show(&enemy_3); - enemy_init(&enemy_4,start_x_pos+45,start_enemy_y_pos,WHITE); + enemy_init(&enemy_4,start_x_pos+45,start_enemy_y_pos,RED); enemy_show(&enemy_4); - enemy_init(&enemy_5,start_x_pos+60,start_enemy_y_pos,WHITE); + enemy_init(&enemy_5,start_x_pos+60,start_enemy_y_pos,RED); enemy_show(&enemy_5); // Second Row of Enemies - enemy_init(&enemy_6,start_x_pos,start_enemy_y_pos+12,WHITE); + enemy_init(&enemy_6,start_x_pos,start_enemy_y_pos+12,RED); enemy_show(&enemy_6); - enemy_init(&enemy_7,start_x_pos+15,start_enemy_y_pos+12,WHITE); + enemy_init(&enemy_7,start_x_pos+15,start_enemy_y_pos+12,RED); enemy_show(&enemy_7); - enemy_init(&enemy_8,start_x_pos+30,start_enemy_y_pos+12,WHITE); + enemy_init(&enemy_8,start_x_pos+30,start_enemy_y_pos+12,RED); enemy_show(&enemy_8); - enemy_init(&enemy_9,start_x_pos+45,start_enemy_y_pos+12,WHITE); + enemy_init(&enemy_9,start_x_pos+45,start_enemy_y_pos+12,RED); enemy_show(&enemy_9); - enemy_init(&enemy_10,start_x_pos+60,start_enemy_y_pos+12,WHITE); + enemy_init(&enemy_10,start_x_pos+60,start_enemy_y_pos+12,RED); enemy_show(&enemy_10); // Third Row of Enemies - enemy_init(&enemy_11,start_x_pos,start_enemy_y_pos+24,WHITE); + enemy_init(&enemy_11,start_x_pos,start_enemy_y_pos+24,RED); enemy_show(&enemy_11); - enemy_init(&enemy_12,start_x_pos+15,start_enemy_y_pos+24,WHITE); + enemy_init(&enemy_12,start_x_pos+15,start_enemy_y_pos+24,RED); enemy_show(&enemy_12); - enemy_init(&enemy_13,start_x_pos+30,start_enemy_y_pos+24,WHITE); + enemy_init(&enemy_13,start_x_pos+30,start_enemy_y_pos+24,RED); enemy_show(&enemy_13); - enemy_init(&enemy_14,start_x_pos+45,start_enemy_y_pos+24,WHITE); + enemy_init(&enemy_14,start_x_pos+45,start_enemy_y_pos+24,RED); enemy_show(&enemy_14); - enemy_init(&enemy_15,start_x_pos+60,start_enemy_y_pos+24,WHITE); + enemy_init(&enemy_15,start_x_pos+60,start_enemy_y_pos+24,RED); enemy_show(&enemy_15); // Put enemy objects into array @@ -812,6 +812,7 @@ int score = 0; // Additional globals added for two-player and one-player capabilities (by Brice) + char buffer[3] = {0}; char c = {0}; char *token; @@ -830,6 +831,7 @@ SDLock.unlock(); token = strtok(buffer, "\n"); storedTime = atoi(token); // convert string from file to integer + // Begin game loop while(1) {