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:
- 27:a1b41626f57c
- Parent:
- 26:abbc19edc5c1
- Child:
- 28:98848e6a77a2
diff -r abbc19edc5c1 -r a1b41626f57c Entity/Player/Player.cpp
--- a/Entity/Player/Player.cpp Mon Apr 29 02:45:17 2019 +0000
+++ b/Entity/Player/Player.cpp Mon Apr 29 10:39:09 2019 +0000
@@ -29,7 +29,15 @@
fire_rate_delay = 30;
velocity = 0.7;
_bullet_speed = 1;
-
+}
+
+Player::~Player()
+{
+ for (int i = 0; i < bullets_max; i++) {
+ if (valid_bullets[i]) {
+ delete bullets_array[i];
+ }
+ }
}
// Accessors
@@ -39,24 +47,24 @@
};
int Player::get_hearts_width()
{
- return hearts.width;
+ return 9;
}
int Player::get_hearts_height()
{
- return hearts.height;
+ return 9;
}
int * Player::get_hearts_sprite()
{
- return hearts.sprite;
+ return (int *) sprite_heart;
}
// Functions
-void Player::move(float mapped_x, float mapped_y)
+void Player::move(float mapped_x, float mapped_y, int * map)
{
- if(!matrix_collision_test(position.x + velocity*mapped_x, position.y, 0)) {
+ if(!matrix_collision_test(position.x + velocity*mapped_x, position.y, map)) {
position.x += velocity*mapped_x;
}
- if(!matrix_collision_test(position.x, position.y - velocity*mapped_y, 0)) {
+ if(!matrix_collision_test(position.x, position.y - velocity*mapped_y, map)) {
position.y -= velocity*mapped_y;
}
moving = false;
@@ -122,21 +130,3 @@
}
}
}
-
-void Player::update_hearts()
-{
- hearts.width = (hp * 10) - 1;
- hearts.height = 9;
- int hearts_sprite[hearts.height][hearts.width];
- for (int j = 0; j < 9; j++) {
- for (int n = 0; n < hp; n++) {
- for (int i = 0; i < 9; i++){
- hearts_sprite[j][i + (n * 10)] = sprite_heart[j][i];
- }
- if (n != hp) {
- hearts_sprite[j][9 + (n * 10)] = 2;
- }
- }
- }
- hearts.sprite = * hearts_sprite;
-}