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 "ConcreteAsteroid1.h"
sralph3 0:f2cc64948895 3 #include "AbsAst.h"
sralph3 0:f2cc64948895 4 #include <math.h>
sralph3 0:f2cc64948895 5 extern int asteroid_sprite_1;
sralph3 0:f2cc64948895 6 extern uLCD_4DGL uLCD;
sralph3 0:f2cc64948895 7
sralph3 0:f2cc64948895 8 #define ASTEROID_HEIGHT 12
sralph3 0:f2cc64948895 9 #define ASTEROID_WIDTH 15
sralph3 0:f2cc64948895 10 #define SPRITE_MAX 15
sralph3 0:f2cc64948895 11 #define SCREEN_MAX 125
sralph3 0:f2cc64948895 12 #define SCREEN_MIN 1
sralph3 0:f2cc64948895 13 #define NUM_ASTEROIDS 4
sralph3 0:f2cc64948895 14
sralph3 0:f2cc64948895 15
sralph3 0:f2cc64948895 16 ConcreteAsteroid1::ConcreteAsteroid1(){
sralph3 0:f2cc64948895 17 //START IN RANDOM XPOS AND ZERO YPOS
sralph3 0:f2cc64948895 18 xpos = (rand() % SCREEN_MAX );
sralph3 0:f2cc64948895 19 ypos = 0;
sralph3 0:f2cc64948895 20 //VELOCITY VECTOR, X VECTOR IS -5 TO +5, Y VECTOR IS 1-11
sralph3 0:f2cc64948895 21 dx = (rand() % 10) - 5;
sralph3 0:f2cc64948895 22 dy = (rand() % 10 +1);
sralph3 0:f2cc64948895 23 }
sralph3 0:f2cc64948895 24
sralph3 0:f2cc64948895 25 void ConcreteAsteroid1::draw(){
sralph3 0:f2cc64948895 26 uLCD.BLIT(xpos, ypos, ASTEROID_WIDTH, ASTEROID_HEIGHT, &asteroid_sprite_1);
sralph3 0:f2cc64948895 27 }
sralph3 0:f2cc64948895 28
sralph3 0:f2cc64948895 29 // MOVE BY ONE UNIT OF THE VELOCITY VECTOR
sralph3 0:f2cc64948895 30 void ConcreteAsteroid1::update(){
sralph3 0:f2cc64948895 31 xpos= xpos + dx;
sralph3 0:f2cc64948895 32 ypos = ypos + dy;
sralph3 0:f2cc64948895 33 }