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: globals.cpp
- Revision:
- 23:56f6a12aaebd
- Child:
- 28:a2dac56af32f
diff -r a907eeb128a4 -r 56f6a12aaebd globals.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/globals.cpp Mon Apr 26 21:53:25 2021 +0000 @@ -0,0 +1,20 @@ +#include "globals.h" +#include "mbed.h" +// Modified from the RPG Game from ECE 2035. Draw more complex player object (with changing color). + +void draw_img(int u, int v, int width, int height, const char* img) +{ + int colors[width*height]; + for (int i = 0; i < width*height; i++) + { + if (img[i] == 'G') colors[i] = GREEN; + else if (img[i] == 'B') colors[i] = BLUE; + else if (img[i] == 'P') colors[i] = PINK; + else if (img[i] == 'U') colors[i] = PURPLE; + else if (img[i] == 'Y') colors[i] = YELLOW; + else if (img[i] == 'R') colors[i] = RED; + else colors[i] = BLACK; + } + uLCD.BLIT(u, v, width, height, colors); + wait_us(250); // Recovery time! +} \ No newline at end of file