diff options
author | Treeki <treeki@gmail.com> | 2012-10-29 12:08:11 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-10-29 12:08:11 +0100 |
commit | 4e43d350d71fcbd90bc8e647aa53fc5152bb1de8 (patch) | |
tree | 16d2c84eab74a0b8eb26d58bc0050c2d8b7cd82c /src/flipblock.cpp | |
parent | dd90d6a3cbd0288a1138122106b9f4f819f5bbba (diff) | |
download | kamek-4e43d350d71fcbd90bc8e647aa53fc5152bb1de8.tar.gz kamek-4e43d350d71fcbd90bc8e647aa53fc5152bb1de8.zip |
quick API update, and flipblock finished
Diffstat (limited to 'src/flipblock.cpp')
-rw-r--r-- | src/flipblock.cpp | 33 |
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; +} + |