Daniel Nguyen

Dependencies:   4DGL-uLCD-SE mbed

Revision:
0:7d7f6032c719
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bullet.cpp	Thu Nov 02 19:15:07 2017 +0000
@@ -0,0 +1,50 @@
+#include "Bullet.h"
+#include "uLCD_4DGL.h"
+#define BULLET_HEIGHT 4
+#define BULLET_WIDTH 4
+#define X 0xFFFFFF
+#include <iostream>
+
+
+Bullet::Bullet()
+{
+    pos_y = 105;
+}
+
+int Bullet::getPosX()
+{
+    return pos_x;
+}
+
+void Bullet::setPosX(int shipX)
+{
+    pos_x = shipX;
+    pos_x-=2;
+}
+
+int Bullet::getPosY()
+{
+    return pos_y;
+}
+
+void Bullet::setPosY(int shipY)
+{
+    pos_y = shipY;
+}
+
+void Bullet::draw()
+{
+    
+    uLCD.filled_rectangle(pos_x, pos_y, pos_x+BULLET_WIDTH, pos_y+BULLET_HEIGHT, BLACK);
+    pos_y -= 2;
+    uLCD.filled_rectangle(pos_x, pos_y, pos_x+4, pos_y+4, WHITE);
+    uLCD.filled_rectangle(pos_x, pos_y, pos_x, pos_y-4, BLACK);
+}
+
+void Bullet::collide()
+{
+    // Just ensures that the bullet does not look like it moves forward when 
+    // it collides
+    uLCD.filled_rectangle(pos_x, pos_y, pos_x + 4, pos_y +4, BLACK); 
+    uLCD.filled_rectangle(pos_x, pos_y, pos_x + 4, pos_y +4, BLACK);
+}