From 1c1521acafbef0a024bfeb3d7408e5d7c8123dda Mon Sep 17 00:00:00 2001 From: Treeki Date: Tue, 12 Feb 2013 02:20:48 +0100 Subject: failed/unfinished thing for the ship collisions --- src/bossCaptainBowser.cpp | 68 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/src/bossCaptainBowser.cpp b/src/bossCaptainBowser.cpp index 4867afb..de3e017 100644 --- a/src/bossCaptainBowser.cpp +++ b/src/bossCaptainBowser.cpp @@ -56,7 +56,8 @@ public: m3d::anmChr_c chrAnimation; m3d::anmChr_c shipAnm; - Physics ShipPhysics; + static const int SHIP_COLL_COUNT = 7; + ActivePhysics shipCollisions[SHIP_COLL_COUNT]; ActivePhysics Roar; mEf::es2 effect; @@ -145,20 +146,23 @@ daCaptainBowser *daCaptainBowser::build() { } } - void ShipPhysicsCallback(daCaptainBowser *self, dEn_c *other) { - if (other->name == 657) { + void ShipAPhysicsCallback(ActivePhysics *apThis, ActivePhysics *apOther) { + daCaptainBowser *self = (daCaptainBowser*)apThis->owner; + if (apOther->owner->name == 657) { OSReport("CANNON COLLISION"); if (self->isInvulnerable) { return; } self->damage -= 1; - SpawnEffect("Wm_en_burst_m", 0, &other->pos, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}); - PlaySound(other, SE_OBJ_TARU_BREAK); - other->Delete(1); + SpawnEffect("Wm_en_burst_m", 0, &apOther->owner->pos, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}); + PlaySound(apOther->owner, SE_OBJ_TARU_BREAK); + apOther->owner->Delete(1); if (self->damage == self->maxDamage/2) { self->doStateChange(&daCaptainBowser::StateID_Roar); } else if (self->damage < 0) { self->doStateChange(&daCaptainBowser::StateID_Outro); } + + apThis->someFlagByte |= 2; } } @@ -216,19 +220,43 @@ int daCaptainBowser::onCreate() { this->damage = this->maxDamage; - // Ship Physics! - // Normal rects are { left, top, right, bottom } - // Callbacks are Touching upwards, Touching Downwards, and unknown - - ShipPhysics.baseSetup(this, (void*)&ShipPhysicsCallback, 0, 0, 1, 0); - - ShipPhysics.x = 8.0; - ShipPhysics.y = 20.0; - - ShipPhysics.diameter = 12.0 * 16.0; - ShipPhysics.isRound = 1; - + for (int i = 0; i < SHIP_COLL_COUNT; i++) { + shipCollisions[i].owner = this; + shipCollisions[i].info.category1 = 3; + shipCollisions[i].info.category2 = 0; + shipCollisions[i].info.bitfield1 = 0x4F; + shipCollisions[i].info.bitfield2 = 0x8028E; + shipCollisions[i].info.unkShort1C = 0; + shipCollisions[i].info.callback = &ShipAPhysicsCallback; + } + static const float xToCentres[] = {-56.541185, 161.824968, 106.258581}; + static const float yToCentres[] = {-91.176745, -66.957921, 57.935231}; + static const float xToEdges[] = {39.481380, 11.698187, 24.371222}; + static const float yToEdges[] = {37.040555, 12.821730, 21.844430}; + static const float trpValues0[] = {-39.481380, -11.698187, -24.371222}; + static const float trpValues1[] = {-39.481380, -11.698187, 24.371222}; + static const float trpValues2[] = {-39.481380, -11.698187, -24.371222}; + static const float trpValues3[] = {39.481380, 11.698187, -24.371222}; + static const float scX1[] = {-176.447600, 64.340078, -157.925471, -157.925471}; + static const float scY1[] = {-128.217300, 112.570378, -109.695171, -109.695171}; + static const float scX2[] = {-176.447600, 64.340078, -157.925471, -157.925471}; + static const float scY2[] = {-128.217300, 112.570378, -109.695171, -109.695171}; + + for (int i = 0; i < SHIP_COLL_COUNT; i++) { + shipCollisions[i].info.xDistToCenter = xToCentres[i]; + shipCollisions[i].info.yDistToCenter = yToCentres[i]; + shipCollisions[i].info.xDistToEdge = xToEdges[i]; + shipCollisions[i].info.yDistToEdge = yToEdges[i]; + if (i >= 4) { + int xi = i - 4; + shipCollisions[i].trpValue0 = trpValues0[xi]; + shipCollisions[i].trpValue1 = trpValues1[xi]; + shipCollisions[i].trpValue2 = trpValues2[xi]; + shipCollisions[i].trpValue3 = trpValues3[xi]; + shipCollisions[i].collisionCheckType = 3; + } + } // Bowser Physics! ActivePhysics::Info BowserPhysics; @@ -280,7 +308,6 @@ int daCaptainBowser::onDelete() { int daCaptainBowser::onExecute() { acState.execute(); - this->ShipPhysics.update(); PlaySound(this, SE_BOSS_SHIP_PRPL); @@ -430,7 +457,8 @@ int daCaptainBowser::onDraw() { } void daCaptainBowser::endState_Intro() { - this->ShipPhysics.addToList(); + for (int i = 0; i < SHIP_COLL_COUNT; i++) + shipCollisions[i].addToList(); this->aPhysics.addToList(); this->isInvulnerable = 0; -- cgit v1.2.3