ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18ajst

Dependencies:   mbed

Committer:
Albutt
Date:
Mon May 25 17:22:06 2020 +0000
Revision:
12:c557b6c9b17a
Parent:
9:62fe47a1374f
Child:
14:2d7e41f46879
Function Clean up

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Albutt 4:b16b6078a432 1 #include "Bullets.h"
Albutt 4:b16b6078a432 2 Serial pcb(USBTX, USBRX);
Albutt 12:c557b6c9b17a 3 Bullets::Bullets(int ex, int wy, int d)
Albutt 4:b16b6078a432 4 {
Albutt 9:62fe47a1374f 5 _dir = 0;
Albutt 7:0434857199cf 6 _x = ex;
Albutt 7:0434857199cf 7 _y = wy;
Albutt 12:c557b6c9b17a 8 _dir = d;
Albutt 7:0434857199cf 9 //pcb.printf("Direction = %d", _dir);
Albutt 4:b16b6078a432 10 }
Albutt 4:b16b6078a432 11
Albutt 4:b16b6078a432 12 Bullets::~Bullets()
Albutt 4:b16b6078a432 13 {
Albutt 4:b16b6078a432 14
Albutt 4:b16b6078a432 15 }
Albutt 4:b16b6078a432 16
Albutt 4:b16b6078a432 17 void Bullets::draw(N5110 &lcd)
Albutt 4:b16b6078a432 18 {
Albutt 5:51fd6635141f 19
Albutt 7:0434857199cf 20 lcd.drawRect(_x,_y,1,1,FILL_BLACK);
Albutt 7:0434857199cf 21 }
Albutt 7:0434857199cf 22
Albutt 7:0434857199cf 23 void Bullets::update()
Albutt 7:0434857199cf 24 {
Albutt 4:b16b6078a432 25 if(_dir == 0){
Albutt 8:0c6d6ed55851 26 _y = _y-3;
Albutt 4:b16b6078a432 27 }
Albutt 4:b16b6078a432 28 else if (_dir == 1){
Albutt 8:0c6d6ed55851 29 _x = _x+3;
Albutt 4:b16b6078a432 30 }
Albutt 4:b16b6078a432 31 else if (_dir == 2){
Albutt 8:0c6d6ed55851 32 _y = _y+3;
Albutt 4:b16b6078a432 33 }
Albutt 4:b16b6078a432 34 else if (_dir == 3){
Albutt 8:0c6d6ed55851 35 _x = _x-3;
Albutt 4:b16b6078a432 36 }
Albutt 4:b16b6078a432 37 }
Albutt 7:0434857199cf 38 int Bullets::get_x(){
Albutt 7:0434857199cf 39 return _x;
Albutt 7:0434857199cf 40 }
Albutt 7:0434857199cf 41
Albutt 7:0434857199cf 42 int Bullets::get_y(){
Albutt 7:0434857199cf 43 return _y;
Albutt 7:0434857199cf 44 }
Albutt 9:62fe47a1374f 45
Albutt 9:62fe47a1374f 46 void Bullets::dead(){
Albutt 9:62fe47a1374f 47 _x = 2147483647;
Albutt 9:62fe47a1374f 48 _y = 1000;
Albutt 9:62fe47a1374f 49 }
Albutt 7:0434857199cf 50