diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-03-29 11:11:11 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-03-29 11:11:11 -0500 |
commit | 2e5153002bccc3722dbacaa62b729493d2c2bf89 (patch) | |
tree | 0d235a689a0d7c831293dff206833f2d8efb277a /src/magicplatform.cpp | |
parent | 128ab59a90b26c54e18f8823adc26d37115fb5f5 (diff) | |
parent | 7bbab722a388bc63ec195a48c22c7060e3fab999 (diff) | |
download | kamek-2e5153002bccc3722dbacaa62b729493d2c2bf89.tar.gz kamek-2e5153002bccc3722dbacaa62b729493d2c2bf89.zip |
merging changes to latest pull
Diffstat (limited to 'src/magicplatform.cpp')
-rw-r--r-- | src/magicplatform.cpp | 100 |
1 files changed, 99 insertions, 1 deletions
diff --git a/src/magicplatform.cpp b/src/magicplatform.cpp index 924d849..e9fa940 100644 --- a/src/magicplatform.cpp +++ b/src/magicplatform.cpp @@ -12,6 +12,10 @@ class daEnMagicPlatform_c : public dEn_c { // Settings u8 rectID, moveSpeed, moveDirection, moveLength; + u8 moveDelay, currentMoveDelay; + + bool doesMoveInfinitely; + float moveMin, moveMax, moveDelta, moveBaseDelta; float *moveTarget; @@ -41,12 +45,87 @@ daEnMagicPlatform_c *daEnMagicPlatform_c::build() { return c; } +extern "C" void HurtMarioBecauseOfBeingSquashed(void *mario, dStageActor_c *squasher, int type); + +static void PhysCB1(daEnMagicPlatform_c *one, dStageActor_c *two) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (one->pos_delta.y > 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 1); + else + HurtMarioBecauseOfBeingSquashed(two, one, 9); +} + +static void PhysCB2(daEnMagicPlatform_c *one, dStageActor_c *two) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (one->pos_delta.y < 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 2); + else + HurtMarioBecauseOfBeingSquashed(two, one, 10); +} + +static void PhysCB3(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) { + if (two->stageActorType != 1) + return; + + // if left/right + if (one->moveDirection <= 1) + return; + + if (unkMaybeNotBool) { + if (one->pos_delta.x > 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 6); + else + HurtMarioBecauseOfBeingSquashed(two, one, 12); + } else { + if (one->pos_delta.x < 0.0f) + HurtMarioBecauseOfBeingSquashed(two, one, 5); + else + HurtMarioBecauseOfBeingSquashed(two, one, 11); + } +} + +static bool PhysCB4(daEnMagicPlatform_c *one, dStageActor_c *two) { + return (one->pos_delta.y > 0.0f); +} + +static bool PhysCB5(daEnMagicPlatform_c *one, dStageActor_c *two) { + return (one->pos_delta.y < 0.0f); +} + +static bool PhysCB6(daEnMagicPlatform_c *one, dStageActor_c *two, bool unkMaybeNotBool) { + if (unkMaybeNotBool) { + if (one->pos_delta.x > 0.0f) + return true; + } else { + if (one->pos_delta.x < 0.0f) + return true; + } + return false; +} + int daEnMagicPlatform_c::onCreate() { rectID = settings & 0xFF; + moveSpeed = (settings & 0xF00) >> 8; moveDirection = (settings & 0x3000) >> 12; moveLength = ((settings & 0xF0000) >> 16) + 1; + moveDelay = ((settings & 0xF00000) >> 20) * 6; + + doesMoveInfinitely = (settings & 0x10000000); + setupMovement(); findSourceArea(); @@ -56,7 +135,11 @@ int daEnMagicPlatform_c::onCreate() { float fHeight = height * 16.0f; physics.setup(this, 0.0f, 0.0f, fWidth, -fHeight, - 0, 0, 0/*&PhysCB1, &PhysCB2, &PhysCB3*/, 1, 0, 0); + &PhysCB1, &PhysCB2, &PhysCB3, 1, 0, 0); + + physics.callback1 = &PhysCB4; + physics.callback2 = &PhysCB5; + physics.callback3 = &PhysCB6; physics.addToList(); @@ -77,6 +160,9 @@ int daEnMagicPlatform_c::onExecute() { updateTilePositions(); physics.update(); + if (doesMoveInfinitely) + checkZoneBoundaries(0); + return 1; } @@ -119,6 +205,8 @@ void daEnMagicPlatform_c::setupMovement() { } else { isMoving = false; } + + currentMoveDelay = 0; } void daEnMagicPlatform_c::handleMovement() { @@ -145,12 +233,21 @@ void daEnMagicPlatform_c::handleMovement() { if (!isMoving) return; + if (currentMoveDelay > 0) { + currentMoveDelay--; + return; + } + // Do it bool goesForward = (moveDelta > 0.0f); bool reachedEnd = false; *moveTarget += moveDelta; + // if we're set to move infinitely, never stop + if (doesMoveInfinitely) + return; + if (goesForward) { if (*moveTarget >= moveMax) { *moveTarget = moveMax; @@ -175,6 +272,7 @@ void daEnMagicPlatform_c::handleMovement() { } else { // Otherwise, reverse moveDelta = -moveDelta; + currentMoveDelay = moveDelay; } } } |