A simple asteroids-like game utilizing various Mbed-compatible sensors
Dependencies: mbed 4DGL-uLCD-SE PinDetect
ConcreteAsteroid2.cpp
- Committer:
- sralph3
- Date:
- 2018-11-30
- Revision:
- 0:f2cc64948895
File content as of revision 0:f2cc64948895:
#include "uLCD_4DGL.h" #include "ConcreteAsteroid2.h" #include "AbsAst.h" #include <math.h> extern int asteroid_sprite_2; 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 ConcreteAsteroid2::ConcreteAsteroid2(){ //START IN RANDOM XPOS AND ZERO YPOS xpos = (rand() % SCREEN_MAX ); ypos = SCREEN_MAX; //VELOCITY VECTOR, X VECTOR IS -5 TO +5, Y VECTOR IS -1 TO -11 dx = (rand() % 10) - 5; dy = (rand() % 10 -11); } void ConcreteAsteroid2::draw(){ uLCD.BLIT(xpos, ypos, ASTEROID_WIDTH, ASTEROID_HEIGHT, &asteroid_sprite_2); } // MOVE BY ONE UNIT OF THE VELOCITY VECTOR void ConcreteAsteroid2::update(){ xpos= xpos + dx; ypos = ypos + dy; }