diff options
author | Treeki <treeki@gmail.com> | 2012-08-30 19:52:41 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-08-30 19:52:41 +0200 |
commit | 2b5bc0f0397e50b7cad585196e403c99d27b6207 (patch) | |
tree | 1614cd5757666b8a5c04ecd0a1ca6b2d8f358497 | |
parent | 13bd79fc484ff3b57d9994d3ea02500a87786715 (diff) | |
download | kamek-2b5bc0f0397e50b7cad585196e403c99d27b6207.tar.gz kamek-2b5bc0f0397e50b7cad585196e403c99d27b6207.zip |
collision types for magic platforms
Diffstat (limited to '')
-rw-r--r-- | src/magicplatform.cpp | 54 |
1 files changed, 45 insertions, 9 deletions
diff --git a/src/magicplatform.cpp b/src/magicplatform.cpp index fe2eb9b..4997945 100644 --- a/src/magicplatform.cpp +++ b/src/magicplatform.cpp @@ -9,7 +9,14 @@ class daEnMagicPlatform_c : public dEn_c { int onExecute(); int onDelete(); + enum CollisionType { + Solid = 0, + SolidOnTop = 1, + None = 2 + }; + // Settings + CollisionType collisionType; u8 rectID, moveSpeed, moveDirection, moveLength; u8 moveDelay, currentMoveDelay; @@ -24,6 +31,7 @@ class daEnMagicPlatform_c : public dEn_c { void handleMovement(); Physics physics; + StandOnTopCollider sotCollider; TileRenderer *renderers; int rendererCount; @@ -129,6 +137,8 @@ int daEnMagicPlatform_c::onCreate() { moveDelay = ((settings & 0xF00000) >> 20) * 6; + collisionType = (CollisionType)((settings & 0x3000000) >> 24); + doesMoveInfinitely = (settings & 0x10000000); setupMovement(); @@ -138,15 +148,35 @@ int daEnMagicPlatform_c::onCreate() { float fWidth = width * 16.0f; float fHeight = height * 16.0f; - physics.setup(this, - 0.0f, 0.0f, fWidth, -fHeight, - &PhysCB1, &PhysCB2, &PhysCB3, 1, 0, 0); - physics.callback1 = &PhysCB4; - physics.callback2 = &PhysCB5; - physics.callback3 = &PhysCB6; + switch (collisionType) { + case Solid: + physics.setup(this, + 0.0f, 0.0f, fWidth, -fHeight, + &PhysCB1, &PhysCB2, &PhysCB3, 1, 0, 0); + + physics.callback1 = &PhysCB4; + physics.callback2 = &PhysCB5; + physics.callback3 = &PhysCB6; + + physics.addToList(); + break; + case SolidOnTop: + sotCollider.init(this, + /*xOffset=*/0.0f, /*yOffset=*/0.0f, + /*topYOffset=*/0, + /*rightSize=*/fWidth, /*leftSize=*/0, + /*rotation=*/0, /*_45=*/1 + ); + + // What is this for. I dunno + sotCollider._47 = 0xA; + sotCollider.flags = 0x80180 | 0xC00; - physics.addToList(); + sotCollider.addToList(); + + break; + } return 1; } @@ -154,7 +184,9 @@ int daEnMagicPlatform_c::onCreate() { int daEnMagicPlatform_c::onDelete() { deleteTiles(); - physics.removeFromList(); + switch (collisionType) { + case Solid: physics.removeFromList(); break; + } return 1; } @@ -165,7 +197,11 @@ int daEnMagicPlatform_c::onExecute() { checkVisibility(); updateTilePositions(); - physics.update(); + + switch (collisionType) { + case Solid: physics.update(); break; + case SolidOnTop: sotCollider.update(); break; + } return 1; } |