A simple asteroids-like game utilizing various Mbed-compatible sensors
Dependencies: mbed 4DGL-uLCD-SE PinDetect
Diff: SSE.cpp
- Revision:
- 0:f2cc64948895
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SSE.cpp Fri Nov 30 04:49:11 2018 +0000 @@ -0,0 +1,43 @@ +#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; + } \ No newline at end of file