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: Enemy4.cpp
- Revision:
- 2:1f2d27210997
- Child:
- 3:c94be48251b5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Enemy4.cpp Tue May 02 22:14:30 2017 +0000
@@ -0,0 +1,42 @@
+#include "Enemy4.h"
+
+Enemy4::Enemy4()
+{
+
+}
+
+Enemy4::~Enemy4()
+{
+
+}
+
+void Enemy4::init(int speed)
+{
+ int x = rand() % 63 + 84;
+ _x = x;
+ _y = 21;
+
+ _velocity.x = -speed;
+ _velocity.y = 0;
+}
+
+void Enemy4::draw(N5110 &lcd)
+{
+ lcd.drawLine(_x,_y,_x,_y+5,1);
+ lcd.drawLine(_x-1,_y,_x-1,_y+5,1);
+ lcd.drawLine(_x-2,_y+1,_x-2,_y+4,1);
+ lcd.drawLine(_x-3,_y+1,_x-3,_y+4,1);
+ lcd.drawLine(_x-4,_y+2,_x-4,_y+3,1);
+}
+
+void Enemy4::update()
+{
+ _x += _velocity.x;
+ _y += _velocity.y;
+}
+
+Vector2D Enemy4::get_pos()
+{
+ Vector2D p = {_x,_y};
+ return p;
+}
\ No newline at end of file