ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

Dependencies:   mbed

Revision:
14:2d7e41f46879
Parent:
12:c557b6c9b17a
--- a/Bullets/Bullets.cpp	Tue May 26 12:49:15 2020 +0000
+++ b/Bullets/Bullets.cpp	Tue May 26 14:33:14 2020 +0000
@@ -1,7 +1,9 @@
 #include "Bullets.h"
 Serial pcb(USBTX, USBRX);
+//constructor defines x, y and the direction of travel
 Bullets::Bullets(int ex, int wy, int d)
 {
+    //direction defaults to zero if the joystick hasn't been used yet
     _dir = 0;
     _x = ex;
     _y = wy;
@@ -13,13 +15,13 @@
 {
 
 }
-
+//draws a 1-by-1 rectangle at x and y
 void Bullets::draw(N5110 &lcd)
 {   
 
     lcd.drawRect(_x,_y,1,1,FILL_BLACK);
 }
-
+//bullets travels in a straight line in a direction
 void Bullets::update()
 {
     if(_dir == 0){
@@ -35,6 +37,7 @@
     _x = _x-3;
     }
 }
+//accessors
 int Bullets::get_x(){
     return _x;
     }
@@ -42,9 +45,10 @@
 int Bullets::get_y(){
     return _y;
     }
-    
+//shots that "die" go offscreen (where main them deletes them in line 224)
+//Avoids vector becoming zero, which causes errors in the GameRun loop
 void Bullets::dead(){
-       _x = 2147483647;
+       _x = 1000;
        _y = 1000;
 }
     
\ No newline at end of file