From 4161c5d1c46436e3b942d707da1b40317e87180e Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 10 Jul 2011 22:06:08 +0200 Subject: custom blocks, states and static initialisers. fuck yeah --- src/testblock.cpp | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) (limited to 'src/testblock.cpp') diff --git a/src/testblock.cpp b/src/testblock.cpp index 45d2ef7..93ba8ea 100644 --- a/src/testblock.cpp +++ b/src/testblock.cpp @@ -5,6 +5,8 @@ class daEnTestBlock_c : public daEnBlockMain_c { public: + typedef State State; + TileRenderer tile; Physics::Info physicsInfo; @@ -12,9 +14,25 @@ public: int onDelete(); int onExecute(); + void calledWhenUpMoveExecutes(); + void calledWhenDownMoveExecutes(); + + void wait_Begin(); + void wait_Execute(); + void wait_End(); + + void blockWasHit(bool isDown); + + static State StateID_Wait; static daEnTestBlock_c *build(); }; +daEnTestBlock_c::State daEnTestBlock_c::StateID_Wait( + "daEnTestBlock_c::StateID_Wait", + &daEnTestBlock_c::wait_Begin, + &daEnTestBlock_c::wait_Execute, + &daEnTestBlock_c::wait_End); + int daEnTestBlock_c::onCreate() { blockInit(pos.y); @@ -42,6 +60,12 @@ int daEnTestBlock_c::onCreate() { tile.y = -(16 + pos.y); tile.tileNumber = 0x30; + //OSReport("Sanity Checks... _414=%x\n", offsetof(dEn_c,_414)); + //OSReport("acState=%x\n", offsetof(dActorMultiState_c,acState)); + //OSReport("_530=%x\n", offsetof(dEn_c,_530)); + + doStateChange(&daEnTestBlock_c::StateID_Wait); + return true; } @@ -57,6 +81,7 @@ int daEnTestBlock_c::onDelete() { int daEnTestBlock_c::onExecute() { + acState.execute(); physics.update(); blockUpdate(); @@ -64,7 +89,9 @@ int daEnTestBlock_c::onExecute() { tile.setVars(scale.x); // now check zone bounds based on state - // todo + if (acState.getCurrentState()->isEqual(&StateID_Wait)) { + checkZoneBoundaries(0); + } return true; } @@ -81,3 +108,57 @@ daEnTestBlock_c *daEnTestBlock_c::build() { return c; } + +void daEnTestBlock_c::blockWasHit(bool isDown) { + OSReport("I'm a block, and I was hit.\n"); + + //This code makes the block unhittable + //physicsInfo.otherCallback1 = 0; + //physicsInfo.otherCallback2 = 0; + //physicsInfo.otherCallback3 = 0; + + physics.setup(this, &physicsInfo, 3, currentLayerID); + //physics.flagsMaybe &= ~0x200; + physics.addToList(); + + doStateChange(&StateID_Wait); +} + + + +void daEnTestBlock_c::calledWhenUpMoveExecutes() { + if (initialY >= pos.y) + blockWasHit(false); +} + +void daEnTestBlock_c::calledWhenDownMoveExecutes() { + if (initialY <= pos.y) + blockWasHit(true); +} + + + +void daEnTestBlock_c::wait_Begin() { +} + +void daEnTestBlock_c::wait_End() { +} + +void daEnTestBlock_c::wait_Execute() { + int result = blockResult(); + + if (result == 0) + return; + + if (result == 1) { + doStateChange(&daEnBlockMain_c::StateID_UpMove); + anotherFlag = 2; + isGroundPound = false; + } else { + doStateChange(&daEnBlockMain_c::StateID_DownMove); + anotherFlag = 1; + isGroundPound = true; + } +} + + -- cgit v1.2.3