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
Fork of el17zl by
Diff: PushingEngine/PushingEngine.cpp
- Revision:
- 7:6f8aeadc4370
- Parent:
- 6:6b083e22cb53
- Child:
- 8:83891ea9a5d9
--- a/PushingEngine/PushingEngine.cpp Thu Apr 11 13:42:34 2019 +0000
+++ b/PushingEngine/PushingEngine.cpp Thu Apr 11 14:14:28 2019 +0000
@@ -135,12 +135,13 @@
//draw the barrier
lcd.drawSprite(barrier_x,barrier_y,8,8,(int *)barrier);
-
+ // ppl
+ _ppl.draw(lcd);
// boxes
_b1.draw(lcd);
_b2.draw(lcd);
- // ppl
- _ppl.draw(lcd);
+
+
}
void PushingEngine::update(Gamepad &pad,int barrier_x,int barrier_y) //
@@ -151,13 +152,17 @@
hold_ppl_box1_wall(pad);
hold_ppl_box2_wall(pad);
- _ppl.update(_bb,_ba,_bx,_by,_temp,barrier_x,barrier_y);
+ Vector2D temp_ppl_pos = _ppl.get_pos();
_b1.update(_s,_bb,_ba,_bx,_by,barrier_x,barrier_y);
_b2.update(_r,_bb,_ba,_bx,_by,barrier_x,barrier_y);
+ _ppl.update(_bb,_ba,_bx,_by,_temp,barrier_x,barrier_y);
_temp = 0;
-
- ppl_box_cover(pad);
+ _s = 0;
+ _r = 0;
+ if (ppl_cover_box(pad)){
+ _ppl.set_pos(temp_ppl_pos);
+ }
}
void PushingEngine::hold_ppl_box1_wall(Gamepad &pad) //
@@ -214,18 +219,13 @@
}
}
-void PushingEngine::ppl_box_cover(Gamepad &pad)
+bool PushingEngine::ppl_cover_box(Gamepad &pad)
{
Vector2D b1_pos = _b1.get_pos();
Vector2D b2_pos = _b2.get_pos();
Vector2D ppl_pos = _ppl.get_pos();
- if (b2_pos.x == ppl_pos.x && b2_pos.y == ppl_pos.y){
- int _t = 2;
- }
- if (b1_pos.x == ppl_pos.x && b1_pos.y == ppl_pos.y){
- int _t = 1;
- }
- else {int _t = 0;}
-
-}
\ No newline at end of file
+ if ((b1_pos.x == ppl_pos.x &&b1_pos.y == ppl_pos.y)||(b2_pos.x == ppl_pos.x &&b2_pos.y == ppl_pos.y)){
+ return true;
+ } else {return false;}
+}
