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 Gamepad N5110 mbed-rtos
Diff: Enemy/Enemy.cpp
- Revision:
- 7:574c66ebd8b0
- Parent:
- 6:1fcfd331c047
--- a/Enemy/Enemy.cpp Wed May 08 10:03:24 2019 +0000
+++ b/Enemy/Enemy.cpp Thu May 09 09:54:50 2019 +0000
@@ -36,21 +36,21 @@
void Enemy::location()
{
- int _speed = 5;
+ int _speed = 5; // distance the enemy moves
srand(time(NULL));
int direction = rand() % 4; // randomise initial direction.
// 4 possibilities. Get random modulo and set location accordingly
- if (direction == 0) {
+ if (direction == 0) { // North
_a = _a;
_b += _speed;
- } else if (direction == 1) {
+ } else if (direction == 1) { //South
_a = _a;
_b -= _speed;
- } else if (direction == 2) {
+ } else if (direction == 2) { //West
_a -= _speed;
_b = _b;
- } else {
+ } else { // East
_a += _speed;
_b = _b;
}
@@ -59,14 +59,14 @@
void Enemy::enemy(N5110 &lcd)
{
- // draws the first enemy
+ // Draws the first enemy
lcd.drawSprite(_a,_b,7,8,(int *)enemy1);
}
-void Enemy::update() // moves the position of the enemy when the enemy dies
+void Enemy::update() // Moves the position of the enemy when the enemy dies
{
- _fast = 2.0; // set at 2 so that it is not too fast
+ _fast = 2.0; // Movement speed = 2 so that it is not too fast
_b+=_speed; // moves the y-position downwards
@@ -74,7 +74,7 @@
}
void Enemy::add_health()
{
- // increments the value of health by 1
+ // adds health
_health++;
}
int Enemy::get_health()