A simple asteroids-like game utilizing various Mbed-compatible sensors

Dependencies:   mbed 4DGL-uLCD-SE PinDetect

Committer:
sralph3
Date:
Thu Jan 03 19:56:27 2019 +0000
Revision:
8:137330cfe63d
Parent:
0:f2cc64948895
Jan 3, 2019

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sralph3 0:f2cc64948895 1 #include "uLCD_4DGL.h"
sralph3 0:f2cc64948895 2 #include "MMA8452.h"
sralph3 0:f2cc64948895 3 #include "SSE.h"
sralph3 0:f2cc64948895 4 #include <math.h>
sralph3 0:f2cc64948895 5
sralph3 0:f2cc64948895 6 //IMPORT THE SPACESHIP SPRITE, LCD OBJECT, AND ACCELEROMETER OBJECT
sralph3 0:f2cc64948895 7 extern int spaceship_earth1;
sralph3 0:f2cc64948895 8 extern uLCD_4DGL uLCD;
sralph3 0:f2cc64948895 9 extern MMA8452 acc;
sralph3 0:f2cc64948895 10
sralph3 0:f2cc64948895 11 #define SPRITE_MAX 15
sralph3 0:f2cc64948895 12 #define EARTH_WIDTH 10
sralph3 0:f2cc64948895 13 #define EARTH_HEIGHT 10
sralph3 0:f2cc64948895 14 #define EXPLOSION1_WIDTH 20
sralph3 0:f2cc64948895 15 #define SCREEN_MAX 125
sralph3 0:f2cc64948895 16 #define SCREEN_MIN 1
sralph3 0:f2cc64948895 17
sralph3 0:f2cc64948895 18 SSE::SSE(){
sralph3 0:f2cc64948895 19 xpos = 0;
sralph3 0:f2cc64948895 20 ypos = 0;
sralph3 0:f2cc64948895 21 x = 0; y = 0; z = 0;
sralph3 0:f2cc64948895 22
sralph3 0:f2cc64948895 23 }
sralph3 0:f2cc64948895 24 void SSE::draw(){
sralph3 0:f2cc64948895 25 uLCD.BLIT(xpos, ypos, EARTH_WIDTH, EARTH_HEIGHT, &spaceship_earth1);
sralph3 0:f2cc64948895 26 }
sralph3 0:f2cc64948895 27
sralph3 0:f2cc64948895 28 void SSE::update(){
sralph3 0:f2cc64948895 29 if(!acc.isXYZReady())
sralph3 0:f2cc64948895 30 {
sralph3 0:f2cc64948895 31 wait(0.01);
sralph3 0:f2cc64948895 32 }
sralph3 0:f2cc64948895 33 else
sralph3 0:f2cc64948895 34 {
sralph3 0:f2cc64948895 35
sralph3 0:f2cc64948895 36 acc.readXYZGravity(&x,&y,&z); //notice this is passed by reference use pointers
sralph3 0:f2cc64948895 37 xpos = y*50+63;
sralph3 0:f2cc64948895 38 ypos = x*50+63;
sralph3 0:f2cc64948895 39 }
sralph3 0:f2cc64948895 40 }
sralph3 0:f2cc64948895 41 bool SSE::outB(){
sralph3 0:f2cc64948895 42 return false;
sralph3 0:f2cc64948895 43 }