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.
Dependencies: mbed
Diff: Enemy/Enemy.cpp
- Revision:
- 20:a359092079b0
- Child:
- 23:9be87557b89a
diff -r 5a7b0cdf013b -r a359092079b0 Enemy/Enemy.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Enemy/Enemy.cpp Thu Apr 25 11:34:01 2019 +0000
@@ -0,0 +1,34 @@
+#include "Enemy.h"
+Enemy::Enemy(){
+}
+Enemy::~Enemy(){
+}
+
+void Enemy::init(float floor_pos_x, float floor_pos_y){ // sets its position
+ _radius = 3;
+ _position.x = floor_pos_x + 4;
+ _position.y = floor_pos_y + 4;
+}
+
+void Enemy::draw(N5110 &lcd){
+ lcd.drawCircle(_position.x, _position.y, _radius, FILL_TRANSPARENT);
+}
+
+void Enemy::update(float floor_pos_x, float floor_pos_y){ // decides if it gets erased
+ bullet_pos_y = b.get_position_y();
+ _position.x = floor_pos_x + 4;
+ _position.y = floor_pos_y + 4;
+ if (_position.y + 3 > bullet_pos_y){
+ _position.x = 90; // out of the screen and if pos x = 90 then lower point
+ }
+}
+
+Vector2D Enemy::get_position(){
+ Vector2D p = {_position.x,_position.y};
+ return p;
+}
+
+void Enemy::set_position(Vector2D pos){
+ _position.x = pos.x;
+ _position.y = pos.y;
+}
\ No newline at end of file