Stephen Ralph / Mbed 2 deprecated Asteroids

Dependencies:   mbed 4DGL-uLCD-SE PinDetect

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SSE.cpp Source File

SSE.cpp

00001 #include "uLCD_4DGL.h"
00002 #include "MMA8452.h"
00003 #include "SSE.h"
00004 #include <math.h>
00005 
00006 //IMPORT THE SPACESHIP SPRITE, LCD OBJECT, AND ACCELEROMETER OBJECT
00007 extern int spaceship_earth1;
00008 extern uLCD_4DGL uLCD;
00009 extern MMA8452 acc;
00010 
00011 #define SPRITE_MAX 15
00012 #define EARTH_WIDTH 10
00013 #define EARTH_HEIGHT 10
00014 #define EXPLOSION1_WIDTH 20
00015 #define SCREEN_MAX 125
00016 #define SCREEN_MIN 1
00017 
00018 SSE::SSE(){
00019     xpos = 0;
00020     ypos = 0;
00021     x = 0; y = 0; z = 0;
00022     
00023     }
00024 void SSE::draw(){
00025         uLCD.BLIT(xpos, ypos, EARTH_WIDTH, EARTH_HEIGHT, &spaceship_earth1);
00026     }
00027     
00028 void SSE::update(){
00029      if(!acc.isXYZReady()) 
00030       {
00031          wait(0.01);
00032       }
00033       else
00034       { 
00035       
00036       acc.readXYZGravity(&x,&y,&z); //notice this is passed by reference use pointers
00037       xpos = y*50+63;
00038       ypos = x*50+63;
00039     }
00040 }
00041 bool SSE::outB(){
00042     return false;
00043     }