A simple asteroids-like game utilizing various Mbed-compatible sensors
Dependencies: mbed 4DGL-uLCD-SE PinDetect
ConcreteAsteroid1.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 "ConcreteAsteroid1.h" #include "AbsAst.h" #include <math.h> extern int asteroid_sprite_1; extern uLCD_4DGL uLCD; #define ASTEROID_HEIGHT 12 #define ASTEROID_WIDTH 15 #define SPRITE_MAX 15 #define SCREEN_MAX 125 #define SCREEN_MIN 1 #define NUM_ASTEROIDS 4 ConcreteAsteroid1::ConcreteAsteroid1(){ //START IN RANDOM XPOS AND ZERO YPOS xpos = (rand() % SCREEN_MAX ); ypos = 0; //VELOCITY VECTOR, X VECTOR IS -5 TO +5, Y VECTOR IS 1-11 dx = (rand() % 10) - 5; dy = (rand() % 10 +1); } void ConcreteAsteroid1::draw(){ uLCD.BLIT(xpos, ypos, ASTEROID_WIDTH, ASTEROID_HEIGHT, &asteroid_sprite_1); } // MOVE BY ONE UNIT OF THE VELOCITY VECTOR void ConcreteAsteroid1::update(){ xpos= xpos + dx; ypos = ypos + dy; }