summaryrefslogtreecommitdiff
path: root/src/testblock.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-07-10 22:06:08 +0200
committerTreeki <treeki@gmail.com>2011-07-10 22:06:08 +0200
commit4161c5d1c46436e3b942d707da1b40317e87180e (patch)
tree7266831f88805ff0fa5f0517e64d8ec2dd8cbb73 /src/testblock.cpp
parent54cbbfb69c8a9562d89f05967ae38011327e8da0 (diff)
downloadkamek-4161c5d1c46436e3b942d707da1b40317e87180e.tar.gz
kamek-4161c5d1c46436e3b942d707da1b40317e87180e.zip
custom blocks, states and static initialisers. fuck yeah
Diffstat (limited to '')
-rw-r--r--src/testblock.cpp83
1 files changed, 82 insertions, 1 deletions
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<daEnTestBlock_c> 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;
+ }
+}
+
+