A simple asteroids-like game utilizing various Mbed-compatible sensors
Dependencies: mbed 4DGL-uLCD-SE PinDetect
SSE.cpp
- Committer:
- sralph3
- Date:
- 2019-01-03
- Revision:
- 8:137330cfe63d
- Parent:
- 0:f2cc64948895
File content as of revision 8:137330cfe63d:
#include "uLCD_4DGL.h" #include "MMA8452.h" #include "SSE.h" #include <math.h> //IMPORT THE SPACESHIP SPRITE, LCD OBJECT, AND ACCELEROMETER OBJECT extern int spaceship_earth1; extern uLCD_4DGL uLCD; extern MMA8452 acc; #define SPRITE_MAX 15 #define EARTH_WIDTH 10 #define EARTH_HEIGHT 10 #define EXPLOSION1_WIDTH 20 #define SCREEN_MAX 125 #define SCREEN_MIN 1 SSE::SSE(){ xpos = 0; ypos = 0; x = 0; y = 0; z = 0; } void SSE::draw(){ uLCD.BLIT(xpos, ypos, EARTH_WIDTH, EARTH_HEIGHT, &spaceship_earth1); } void SSE::update(){ if(!acc.isXYZReady()) { wait(0.01); } else { acc.readXYZGravity(&x,&y,&z); //notice this is passed by reference use pointers xpos = y*50+63; ypos = x*50+63; } } bool SSE::outB(){ return false; }