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 | |
parent | dd90d6a3cbd0288a1138122106b9f4f819f5bbba (diff) | |
download | kamek-4e43d350d71fcbd90bc8e647aa53fc5152bb1de8.tar.gz kamek-4e43d350d71fcbd90bc8e647aa53fc5152bb1de8.zip |
quick API update, and flipblock finished
Diffstat (limited to 'src')
-rw-r--r-- | src/apDebug.cpp | 7 | ||||
-rw-r--r-- | src/flipblock.cpp | 33 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/apDebug.cpp b/src/apDebug.cpp index f534e58..a352d4a 100644 --- a/src/apDebug.cpp +++ b/src/apDebug.cpp @@ -109,6 +109,13 @@ void APDebugDrawer::drawXlu() { ActivePhysics *ap = ActivePhysics::globalListHead; while (ap) { +// if (ap->owner->name == PLAYER) +// OSReport("Player has : DistToC=%f,%f DistToEdge=%f,%f Pos=%f,%f Scale=%f,%f\n", +// ap->info.xDistToCenter, ap->info.yDistToCenter, +// ap->info.xDistToEdge, ap->info.yDistToEdge, +// ap->owner->pos.x, ap->owner->pos.y, +// ap->owner->scale.x, ap->owner->scale.y); + u32 uptr = (u32)ap; u8 r = (uptr>>16)&0xFF; u8 g = (uptr>>8)&0xFF; 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; +} + |