Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Bullets/Bullets.cpp
- 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