diff options
author | Stephen Simpson <megazig@gmail.com> | 2011-10-14 00:35:39 -0500 |
---|---|---|
committer | Stephen Simpson <megazig@gmail.com> | 2011-10-14 00:35:39 -0500 |
commit | 1897a8a60cec5bf43bf5cf04cc6b188138aed3ee (patch) | |
tree | 8b075ca427fce385425c5d530e3a3074eaeb9279 /src/bossMegaGoomba.cpp | |
parent | b3c762b06e3238208ba54651545ca51b23e008c9 (diff) | |
parent | 48713b7a405c95022e85f4cf5ce7c27363815d74 (diff) | |
download | kamek-1897a8a60cec5bf43bf5cf04cc6b188138aed3ee.tar.gz kamek-1897a8a60cec5bf43bf5cf04cc6b188138aed3ee.zip |
Merge branch 'megaTestBoss' into level-select
Diffstat (limited to '')
-rw-r--r-- | src/bossMegaGoomba.cpp | 193 |
1 files changed, 108 insertions, 85 deletions
diff --git a/src/bossMegaGoomba.cpp b/src/bossMegaGoomba.cpp index 36f521c..e836afb 100644 --- a/src/bossMegaGoomba.cpp +++ b/src/bossMegaGoomba.cpp @@ -1,6 +1,7 @@ #include <common.h> #include <game.h> #include <g3dhax.h> +#include <sfx.h> #include "player.h" @@ -11,7 +12,14 @@ class daMegaGoomba_c : public dEn_c { int onDraw(); mHeapAllocator_c allocator; + nw4r::g3d::ResFile resFile; m3d::mdl_c bodyModel; + m3d::anmChr_c animationChr; + nw4r::g3d::ResAnmTexPat resTexPat; + m3d::anmTexPat_c animationPat; + //mAllocator_c allocator2; + //FIXME add this back in ? + //EGG::Effect effect; float timer; float dying; @@ -20,8 +28,6 @@ class daMegaGoomba_c : public dEn_c { unsigned int Xkey_count; HermiteKey keysY[0x10]; unsigned int Ykey_count; -// HermiteKey keysZ[0x10]; -// unsigned int Zkey_count; char life; @@ -32,33 +38,17 @@ class daMegaGoomba_c : public dEn_c { u32 marker2_start; int pickedChoice; u32 marker2_end; - u32 marker3_start; float XSpeed; - u32 marker3_end; - u32 marker4_start; float JumpHeight; - u32 marker4_end; - u32 marker5_start; float JumpDist; - u32 marker5_end; - u32 marker6_start; float JumpTime; - u32 marker6_end; - u32 marker7_start; - int playIt; - u32 marker7_end; - u32 marker8_start; - int toPlay; - u32 marker8_end; - u32 marker9_start; - bool timeToPlay; - u32 marker9_end; bool takeHit(char count); void dieFall_Execute(); static daMegaGoomba_c *build(); + void setupBodyModel(); void updateModelMatrices(); // bool preSpriteCollision(ActivePhysics *apThis, ActivePhysics *apOther); @@ -92,16 +82,15 @@ class daMegaGoomba_c : public dEn_c { DECLARE_STATE(Launch); }; -extern "C" void *PlaySound(dStageActor_c *, int soundID); -//extern void * HandleXSpeed(daMegaGoomba_c*); -//extern void * HandleYSpeed(daMegaGoomba_c*); - daMegaGoomba_c *daMegaGoomba_c::build() { void *buffer = AllocFromGameHeap1(sizeof(daMegaGoomba_c)); return new(buffer) daMegaGoomba_c; } +extern "C" void *PlaySound(daMegaGoomba_c *, int soundID); + +//FIXME makes these dEn_c::HandleXSpeed(); extern "C" void *HandleXSpeed(daMegaGoomba_c *); extern "C" void *HandleYSpeed(daMegaGoomba_c *); extern "C" void *UpdateObjectPosBasedOnSpeedValues_real(daMegaGoomba_c *); @@ -126,6 +115,10 @@ bool daMegaGoomba_c::takeHit(char count) { c = 127 - l; } this->life -= c; + this->XSpeed += 0.25; + this->JumpHeight += 12.0; + this->JumpDist += 12.0; + this->JumpTime += 5.0; doStateChange(&StateID_Shrink); setNewActivePhysicsRect(this, &this->scale); return (life <= 0) ? true : false; @@ -189,27 +182,63 @@ void daMegaGoomba_c::dieFall_Execute() { this->dEn_c::dieFall_Execute(); } -int daMegaGoomba_c::onCreate() { +void HexDump(char* address, u32 length) { + length = (length + 0x1f) & ~0x1f; + char line[0x11] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + for(u32 ii=0; ii < length; ii += 0x10) { + for(u32 jj=0; jj < 0x10; jj++) { + line[jj] = address[ii+jj]; + } + OSReport("%08x: %04x %04x %04x %04x %04x %04x %04x %04x |%s|\n", + (u32)(address+ii), + *(u16*)(address+ii+0x00), + *(u16*)(address+ii+0x02), + *(u16*)(address+ii+0x04), + *(u16*)(address+ii+0x06), + *(u16*)(address+ii+0x08), + *(u16*)(address+ii+0x0a), + *(u16*)(address+ii+0x0c), + *(u16*)(address+ii+0x0e), + line); + for(u32 jj=0; jj<0x10; jj++) line[jj] = 0; + } +} - OSReport("Creating the MegaGoomba Model\n"); +void daMegaGoomba_c::setupBodyModel() { allocator.link(-1, GameHeaps[0], 0, 0x20); - nw4r::g3d::ResFile rf(getResource("kuribo", "g3d/t02.brres")); - bodyModel.setup(rf.GetResMdl("kuribo"), &allocator, 0x224, 1, 0); + this->resFile.data = getResource("kuribo", "g3d/t02.brres"); + nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kuribo"); + bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&bodyModel, 0); + bool ret; + nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); + ret = this->animationChr.setup(mdl, anmChr, &this->allocator, 0); + + nw4r::g3d::ResAnmTexPat anmPat = this->resFile.GetResAnmTexPat("walk"); + this->resTexPat = anmPat; + ret = this->animationPat.setup(mdl, anmPat, &this->allocator, 0, 1); + this->animationPat.bindEntry(&this->bodyModel, &anmPat, 0, 0); + this->bodyModel.bindAnim(&this->animationPat, 1.0); + this->animationPat.setFrameForEntry(1.0, 0); + + allocator.unlink(); +} - OSReport("Creating MegaGoomba's Physics Struct\n"); +int daMegaGoomba_c::onCreate() { - // Keeping naming + OSReport("Creating MG's body model\n"); + setupBodyModel(); + + OSReport("Creating MegaGoomba's Physics Struct\n"); + //TODO find data for a fun, yet challenging, battle ActivePhysics::Info HitMeBaby; HitMeBaby.xDistToCenter = 0.0; HitMeBaby.yDistToCenter = 18.0; HitMeBaby.xDistToEdge = 24.0; HitMeBaby.yDistToEdge = 24.0; - - //TODO find data for a fun, yet challenging, battle HitMeBaby.category1 = 0x3; HitMeBaby.category2 = 0x0; HitMeBaby.bitfield1 = 0x4f; @@ -217,14 +246,17 @@ int daMegaGoomba_c::onCreate() { HitMeBaby.unkShort1C = 0; HitMeBaby.callback = &dEn_c::collisionCallback; - - OSReport("Making the Physics Class and adding to the list\n"); this->aPhysics.initWithStruct(this, &HitMeBaby); this->aPhysics.addToList(); + //sub_80034060(); + + //FIXME move this stuff elsewhere pos.y -= 16.0; pos.z = 3000.0; - rot.x = rot.y = rot.z = speed.x = dying = 0.0; + speed.x = dying = 0.0; + rot.x = rot.z = 0; + rot.y = 0x2000; // 0x2000 is left. 0xe000 is for right. direction = 0; life = 3; //TODO 1) allow setting bounding rect with settings @@ -239,28 +271,13 @@ int daMegaGoomba_c::onCreate() { this->marker1_end = 0xaabbff11; this->marker2_start = 0xaabbcc12; this->marker2_end = 0xaabbff12; - this->marker3_start = 0xaabbcc13; - this->marker3_end = 0xaabbff13; - this->marker4_start = 0xaabbcc14; - this->marker4_end = 0xaabbff14; - this->marker5_start = 0xaabbcc15; - this->marker5_end = 0xaabbff15; - this->marker6_start = 0xaabbcc16; - this->marker6_end = 0xaabbff16; - this->marker7_start = 0xaabbcc17; - this->marker7_end = 0xaabbff17; - this->marker8_start = 0xaabbcc18; - this->marker8_end = 0xaabbff18; - this->marker9_start = 0xaabbcc19; - this->marker9_end = 0xaabbff19; + this->pickedChoice = -1; - this->XSpeed = 2.0; // GOOD FOR FINAL SPEED? + // 2.0 is good final speed + this->XSpeed = 1.5; this->JumpHeight = 48.0; this->JumpDist = 64.0; this->JumpTime = 50.0; - this->playIt = 0; - this->toPlay = 0; - this->timeToPlay = false; OSReport("Setting MegaGoomba's State\n"); doStateChange(&StateID_Grow); @@ -292,6 +309,8 @@ int daMegaGoomba_c::onExecute() { int daMegaGoomba_c::onDraw() { bodyModel.scheduleForDrawing(); + animationChr.process(); + animationPat.process(); return true; } @@ -302,10 +321,12 @@ void daMegaGoomba_c::updateModelMatrices() { if(this->life > 0) { if(this->pos.x < this->Bounding.left) { this->direction = !this->direction; + rot.y = (this->direction) ? 0xe000 : 0x2000; this->speed.x = -this->speed.x; this->pos.x = this->Bounding.left; } else if (this->pos.x > this->Bounding.right) { this->direction = !this->direction; + rot.y = (this->direction) ? 0xe000 : 0x2000; this->speed.x = -this->speed.x; this->pos.x = this->Bounding.right; } @@ -358,9 +379,8 @@ void daMegaGoomba_c::executeState_Grow() { setNewActivePhysicsRect(this, &this->scale); } - //TODO grow sound - //if(this->timer == 60.0) - // PlaySound(this, SE_GROW); + if(this->timer == 60.0) + PlaySound(this, SE_EMY_KURI_CHANGE_BIG); if (this->timer > 170.0) { doStateChange(&StateID_Walk); } @@ -384,9 +404,8 @@ void daMegaGoomba_c::executeState_Shrink() { this->scale = (Vec){modifier, modifier, modifier}; setNewActivePhysicsRect(this, &this->scale); - //TODO shrink sound - //if(this->timer == 2.0) - // PlaySound(this, SE_SHRINK); + if(this->timer == 2.0) + PlaySound(this, SE_EMY_KURIBO_L_DAMAGE_02); if (this->timer > 60.0) { doStateChange(&StateID_Walk); } } @@ -405,8 +424,8 @@ void daMegaGoomba_c::executeState_Launch() { this->rot.y = sin(this->timer * 3.14 / 5) * 4000; dStageActor_c *spawner = NULL; - // 120ticks / 80numbers * 4cases = 6avg kuribo - int randChoice = GenerateRandomNumber(80); + // 120ticks / 120numbers * 3cases = 3avg kuribo + int randChoice = GenerateRandomNumber(120); int randChoiceX = GenerateRandomNumber(12); int randChoiceY = GenerateRandomNumber(7); switch(randChoice) { @@ -429,12 +448,6 @@ void daMegaGoomba_c::executeState_Launch() { spawner->speed.y = randChoiceY + 3.0; spawner->scale = (Vec){1.0, 1.0, 1.0}; break; - case 4: - spawner = CreateActor(EN_MAME_KURIBO, 0, this->pos, 0, 0); - spawner->speed.x = randChoiceX - 6.0; - spawner->speed.y = randChoiceY + 3.0; - spawner->scale = (Vec){1.0, 1.0, 1.0}; - break; default: break; }; @@ -444,7 +457,7 @@ void daMegaGoomba_c::executeState_Launch() { this->timer = this->timer + 1.0; } void daMegaGoomba_c::endState_Launch() { - this->rot.y = 0; + rot.y = (this->direction) ? 0xe000 : 0x2000; } // Jump State @@ -491,13 +504,37 @@ void daMegaGoomba_c::endState_Jump() { } void daMegaGoomba_c::beginState_Walk() { this->timer = 1.0; this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, this->pos); - //TODO add rot.changing on switching directions until animations added + rot.y = (this->direction) ? 0xe000 : 0x2000; + + //SETUP WALK ANIMATION// + nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("walk"); + this->animationChr.bind(&this->bodyModel, anmChr, 0); + this->bodyModel.bindAnim(&this->animationChr, 2.0); + /*this->animationChr._setUpdateRate(2.0); FIXME*/ + this->bodyModel.bindAnim(&this->animationPat, 0.0); + this->animationPat.setUpdateRateForEntry(1.0, 0); + this->animationPat.setEntryByte34(0, 0); + float num = (float)GenerateRandomNumber(0xB4); + this->animationPat.setFrameForEntry(num, 0); } void daMegaGoomba_c::executeState_Walk() { - + /* + nw4r::g3d::ResMdl mdl* = this->bodyModel.GetResMdl(); + ResNode resNode = mdl->GetResNode("leg_left"); + resNode._C; + mMtx mtx; + this->bodyModel.GetSomeMatrix(resNode._C, &mtx); + Vec vctr; + ConvertMatrixToTranslationVector(&mtx, &vctr); + */ + + //HandleAcceleration(this); + //HandleXSpeed(this); + //UpdateObjectPosBasedOnSpeedValues_real(this); + //DoGravityMaybe(); float delta = (this->direction) ? -this->XSpeed : this->XSpeed; this->pos.x += delta; - + int Choice; float TimerMax = 150.0; if (this->timer > TimerMax) { @@ -514,23 +551,9 @@ void daMegaGoomba_c::executeState_Walk() { case 1: doStateChange(&StateID_Launch); break; - case 2: - break; - //FIXME test case for sound effects - case 3: - OSReport("PlaySound(this, %d)\n", this->toPlay); - if(this->timeToPlay) { - PlaySound(this, this->toPlay); - this->timeToPlay = false; - this->toPlay++; - if(this->toPlay > 1977) - this->toPlay = 0; - } else { - this->timeToPlay = true; - } - break; default: this->direction = dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(this, pos); + rot.y = (this->direction) ? 0xe000 : 0x2000; this->timer = 0; break; }; |