ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

Dependencies:   mbed

Revision:
4:b16b6078a432
Child:
5:51fd6635141f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Bullets/Bullets.cpp	Mon May 18 15:42:26 2020 +0000
@@ -0,0 +1,52 @@
+#include "Bullets.h"
+Serial pcb(USBTX, USBRX);
+Bullets::Bullets()
+{
+
+}
+
+Bullets::~Bullets()
+{
+
+}
+
+void Bullets::init(int ex, int wy, int d)
+{
+    _size = 1;
+    _speed = 4;
+    _x = ex;
+    _y = wy;
+
+    if (d == 0) {
+        _dir = 0;
+    } else if (d == 1) {
+        _dir = 1;
+    } else if (d == 2) {
+        _dir = 2;
+    } else {
+        _dir = 3;
+    }
+    //pcb.printf("Direction = %d", _dir);
+}
+
+void Bullets::draw(N5110 &lcd)
+{   
+    if(_dir == 0){
+    lcd.drawLine(_x,_y, _x, 0,2);
+    }
+    else if (_dir == 1){
+    lcd.drawLine(_x,_y, WIDTH, _y,2);
+    }
+    else if (_dir == 2){
+    lcd.drawLine(_x,_y, _x, HEIGHT,2);
+    }
+    else if (_dir == 3){
+    lcd.drawLine(_x,_y, 0, _y,2);
+    }
+}
+
+void Bullets::update(int ex, int wy)
+{
+    _x = ex;
+    _y = wy;
+}
\ No newline at end of file