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:
- 41:0697508a28ba
- Parent:
- 40:cbcbf6fc1421
- Child:
- 50:2c5cb92a5361
--- a/Entity/Player/Player.cpp Tue May 07 12:42:12 2019 +0000
+++ b/Entity/Player/Player.cpp Tue May 07 17:02:30 2019 +0000
@@ -66,12 +66,13 @@
void Player::move_player(float mapped_x, float mapped_y, char * map, bool * doorways)
{
- if(!entity_to_map_collision_test(position.x + velocity*mapped_x, position.y, map, doorways)) {
- position.x += velocity*mapped_x;
- }
- if(!entity_to_map_collision_test(position.x, position.y - velocity*mapped_y, map, doorways)) {
- position.y -= velocity*mapped_y;
- }
+ update_prev_pos();
+ position.y -= velocity*mapped_y;
+ position.x += velocity*mapped_x;
+
+ undo_move_x(entity_to_map_collision_test(position.x, prev_pos.y, map, doorways));
+ undo_move_y(entity_to_map_collision_test(prev_pos.x, position.y, map, doorways));
+
moving = false;
}
@@ -191,7 +192,7 @@
if (button_Y || button_B || button_A || button_X) {
for (int i = 0; i < bullets_max; i++) {
if (!valid_bullets[i] && (fire_rate_counter >= fire_rate_delay)) {
- bullets_array[i] = new Bullets(position.x+2, position.y-2, face);
+ bullets_array[i] = new Bullets(position.x+2, position.y+2, face);
valid_bullets[i] = true;
fire_rate_counter = 0;
break;