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
Enemy/Enemy.cpp
- Committer:
- el17m2h
- Date:
- 2019-04-25
- Revision:
- 20:a359092079b0
- Child:
- 23:9be87557b89a
File content as of revision 20:a359092079b0:
#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; }