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

Dependencies:   mbed 4DGL-uLCD-SE PinDetect

Revision:
0:f2cc64948895
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ConcreteAsteroid2.cpp	Fri Nov 30 04:49:11 2018 +0000
@@ -0,0 +1,33 @@
+#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;
+}
\ No newline at end of file