summaryrefslogtreecommitdiff
path: root/src/flipblock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/flipblock.cpp')
-rw-r--r--src/flipblock.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/flipblock.cpp b/src/flipblock.cpp
index a9db0fa..64e6aed 100644
--- a/src/flipblock.cpp
+++ b/src/flipblock.cpp
@@ -17,6 +17,8 @@ public:
void blockWasHit(bool isDown);
+ bool playerOverlaps();
+
mHeapAllocator_c allocator;
nw4r::g3d::ResFile resFile;
m3d::mdl_c model;
@@ -171,7 +173,8 @@ void daEnFlipBlock_c::executeState_Flipping() {
if (rot.x == 0) {
flipsRemaining--;
if (flipsRemaining <= 0) {
- doStateChange(&StateID_Wait);
+ if (!playerOverlaps())
+ doStateChange(&StateID_Wait);
}
}
}
@@ -180,3 +183,31 @@ void daEnFlipBlock_c::endState_Flipping() {
physics.addToList();
}
+
+
+bool daEnFlipBlock_c::playerOverlaps() {
+ dStageActor_c *player = 0;
+
+ Vec myBL = {pos.x - 8.0f, pos.y - 8.0f, 0.0f};
+ Vec myTR = {pos.x + 8.0f, pos.y + 8.0f, 0.0f};
+
+ while ((player = (dStageActor_c*)fBase_c::search(PLAYER, player)) != 0) {
+ float centerX = player->pos.x + player->aPhysics.info.xDistToCenter;
+ float centerY = player->pos.y + player->aPhysics.info.yDistToCenter;
+
+ float left = centerX - player->aPhysics.info.xDistToEdge;
+ float right = centerX + player->aPhysics.info.xDistToEdge;
+
+ float top = centerY + player->aPhysics.info.yDistToEdge;
+ float bottom = centerY - player->aPhysics.info.yDistToEdge;
+
+ Vec playerBL = {left, bottom + 0.1f, 0.0f};
+ Vec playerTR = {right, top - 0.1f, 0.0f};
+
+ if (RectanglesOverlap(&playerBL, &playerTR, &myBL, &myTR))
+ return true;
+ }
+
+ return false;
+}
+