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 MotionSensor
Diff: Entity/Player/Player.cpp
- Revision:
- 28:98848e6a77a2
- Parent:
- 27:a1b41626f57c
- Child:
- 29:6b8411bb040a
diff -r a1b41626f57c -r 98848e6a77a2 Entity/Player/Player.cpp
--- a/Entity/Player/Player.cpp Mon Apr 29 10:39:09 2019 +0000
+++ b/Entity/Player/Player.cpp Thu May 02 21:30:49 2019 +0000
@@ -4,6 +4,7 @@
// Constructor
Player::Player(float pos_x, float pos_y)
{
+ _damage_self_upon_collision = true;
moving = false;
face = 0;
hp = 3;
@@ -36,6 +37,7 @@
for (int i = 0; i < bullets_max; i++) {
if (valid_bullets[i]) {
delete bullets_array[i];
+ valid_bullets[i] = false;
}
}
}
@@ -93,10 +95,16 @@
void Player::take_damage(int damage)
{
- if (invulnerability_counter >= invulnerability_period) {
+ if (damage < 0){
+ hp -= damage;
+ }
+ else if (invulnerability_counter >= invulnerability_period) {
hp -= damage;
invulnerability_counter = 0;
}
+ if (hp > 5) {
+ hp = 5;
+ }
}
int * Player::get_frame()