diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-06-25 00:03:38 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-06-25 00:03:38 -0500 |
commit | caf65b91a27b583dc439c4e71561b818878d83d3 (patch) | |
tree | 658057992852a98a2e26a31601a644a496c419fe /src | |
parent | 434630026ceec18b47c58fc81afbde1e706f8fee (diff) | |
download | kamek-caf65b91a27b583dc439c4e71561b818878d83d3.tar.gz kamek-caf65b91a27b583dc439c4e71561b818878d83d3.zip |
Worked more on bonus room - light is broken, and the delete functions are probably broken
Diffstat (limited to '')
-rw-r--r-- | src/bonusRoom.cpp | 288 |
1 files changed, 101 insertions, 187 deletions
diff --git a/src/bonusRoom.cpp b/src/bonusRoom.cpp index abb81cb..1188528 100644 --- a/src/bonusRoom.cpp +++ b/src/bonusRoom.cpp @@ -14,7 +14,7 @@ int Songs[2][4][15][2] = { { // Song 1 - {{3,0},{3,15},{3,45},{1,75},{3,90},{5,120},{0,0}}, // First number is the note, Second is timing: 30 is one quarter note at 120 bpm, 0,0 ends the sequence - {{8,0},{5,22},{3,45},{6,67},{7,82},{6,97},{6,105},{0,0}}, + {{1,0},{5,22},{3,45},{6,67},{7,82},{6,97},{6,105},{0,0}}, {{1,0},{1,7},{1,22},{1,37},{2,45},{3,60},{1,67},{7,82},{6,90},{0,0}}, {{1,0},{1,7},{1,22},{1,37},{2,45},{3,52},{0,0}} }, @@ -28,7 +28,6 @@ int Songs[2][4][15][2] = { }; - const char* Prizes[10][4] = { { "I_kinoko", "g3d/I_kinoko.brres", "I_kinoko", "wait2" }, { "I_fireflower", "g3d/I_fireflower.brres", "I_fireflower", "wait2" }, @@ -87,7 +86,8 @@ class dSongBlock; /*****************************************************************************/ // The Prize Model -class dSongPrize: public dStageActor_c { +class dSongPrize: public dEn_c { +public: int onCreate(); int onDelete(); int onExecute(); @@ -100,6 +100,7 @@ class dSongPrize: public dStageActor_c { m3d::anmChr_c aw; int queue; + int timer; HermiteKey keysX[0x10]; unsigned int Xkey_count; @@ -110,11 +111,13 @@ class dSongPrize: public dStageActor_c { USING_STATES(dSongPrize); DECLARE_STATE(Wait); + DECLARE_STATE(Shrink); static dSongPrize *build(); }; CREATE_STATE(dSongPrize, Wait); +CREATE_STATE(dSongPrize, Shrink); dSongPrize *dSongPrize::build() { void *buffer = AllocFromGameHeap1(sizeof(dSongPrize)); @@ -124,12 +127,12 @@ dSongPrize *dSongPrize::build() { int dSongPrize::onCreate() { // Settings - int i = this->settings & 0xF; - queue = this->settings >> 16; - scale = (Vec){ 5.0, 5.0, 5.0 }; + queue = this->settings & 0xF; + int prize = this->settings >> 16; + scale = (Vec){ 3.0, 3.0, 3.0 }; int p; - p = PrizePacks[prize][i]; + p = PrizePacks[prize][queue]; // Model creation allocator.link(-1, GameHeaps[0], 0, 0x20); @@ -143,7 +146,7 @@ int dSongPrize::onCreate() { nw4r::g3d::ResAnmChr anmChr = resFile.GetResAnmChr("wait2"); aw.setup(mdl, anmChr, &allocator, 0); aw.bind(&bodyModel, anmChr, 1); - bodyModel.bindAnim(&glow, 0.0); + bodyModel.bindAnim(&aw, 0.0); aw.setUpdateRate(1.0); allocator.unlink(); @@ -161,23 +164,55 @@ int dSongPrize::onExecute() { return true; } - int dSongPrize::onDraw() { matrix.translation(pos.x, pos.y, pos.z); matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); bodyModel.setDrawMatrix(matrix); - Vec myScale = (Vec){scale.x * 1.0, scale.y * 1.0, scale.z * 1.0}; - bodyModel.setScale(&myScale); + bodyModel.setScale(&scale); bodyModel.calcWorld(false); bodyModel.scheduleForDrawing(); + bodyModel._vf1C(); + + if(this->aw.isAnimationDone()) + this->aw.setCurrentFrame(0.0); + return true; } void dSongPrize::beginState_Wait() {} void dSongPrize::endState_Wait() {} -void dSongPrize::executeState_Wait() { +void dSongPrize::executeState_Wait() {} + +void dSongPrize::beginState_Shrink() { + this->timer = 0; + + Xkey_count = 2; + Ykey_count = 2; + Skey_count = 2; + + // /* keysX[i] = { frame, value, slope }; */ + keysX[0] = (HermiteKey){ 0.0, pos.x, 0.8 }; + keysY[0] = (HermiteKey){ 0.0, pos.y, 0.8 }; + keysS[0] = (HermiteKey){ 0.0, 3.0, 0.8 }; + + keysX[1] = (HermiteKey){ 60.0, pos.x + (30.0 * queue) - 172.0, 1.0 }; + keysY[1] = (HermiteKey){ 60.0, pos.y + 64.0, 1.0 }; + keysS[1] = (HermiteKey){ 60.0, 1.0, 1.0 }; +} +void dSongPrize::endState_Shrink() {} +void dSongPrize::executeState_Shrink() { + float modX = GetHermiteCurveValue(timer, keysX, Xkey_count); + float modY = GetHermiteCurveValue(timer, keysY, Ykey_count); + float modS = GetHermiteCurveValue(timer, keysS, Skey_count); + + pos = (Vec){ modX, modY, pos.z }; + scale = (Vec){ modS, modS, modS }; + + if (timer == 60) { doStateChange(&StateID_Wait); } + + timer += 1; } @@ -204,36 +239,21 @@ class dSingAlong : public dStageActor_c { dSingAlong() : state(this, &StateID_Intro) { } mHeapAllocator_c allocator; - nw4r::g3d::ResFile resFile[4]; - m3d::mdl_c pModel[4]; - m3d::anmChr_c pAnim[4]; - Vec prizePos[4]; - Vec prizeScale[4]; - - HermiteKey keysX[0x10]; - unsigned int Xkey_count; - HermiteKey keysY[0x10]; - unsigned int Ykey_count; - HermiteKey keysS[0x10]; - unsigned int Skey_count; - - - dSongBlock *Cblock; - dSongBlock *Dblock; - dSongBlock *Eblock; - dSongBlock *Fblock; - dSongBlock *Gblock; - dSongBlock *Ablock; - dSongBlock *Bblock; - - - // you might get casting issues. due to C++. blah = (int (*)[15][2])BigArray; fixes it - // int (*song)[4][15][2]; - // int (*prizes)[4]; + + dSongPrize *PrizeModel; + // dSongBlock *SongBlocks[7]; + + dSongBlock *SBa; + dSongBlock *SBb; + dSongBlock *SBc; + dSongBlock *SBd; + dSongBlock *SBe; + dSongBlock *SBf; + dSongBlock *SBg; + int song; int prize; int chorus; - // int (*currentNote)[2]; int currentNote; int endNote; int timer; @@ -270,12 +290,9 @@ int dSingAlong::onCreate() { OSReport("Creating the Sing Along gang."); // Load in the settings - // this->song = Songs; this->song = this->settings & 0xF; - // this->prizes = PrizePacks; this->prize = (this->settings >> 4) & 0xF; this->chorus = -1; - // this->currentNote = song[chorus][0]; this->currentNote = 0; this->Powerups[0] = 0; // Mushroom @@ -289,61 +306,27 @@ int dSingAlong::onCreate() { this->Powerups[8] = 0; // 1-ups this->Powerups[9] = 0; // Coins - // Load in the prize models - allocator.link(-1, GameHeaps[0], 0, 0x20); - - int p; - nw4r::g3d::ResMdl mdl; - nw4r::g3d::ResAnmChr anmChr; - - for (int i = 0; i < 4; i++) { - p = PrizePacks[prize][i]; - - // nw4r::g3d::ResFile file; - // resFile[i] = file; - // m3d::mdl_c model; - // pModel[i] = model; - // m3d::anmChr_c anim; - // pAnim[i] = anim; - - OSReport("Model %d: %s, %s, %s", i, Prizes[p][0], Prizes[p][1], Prizes[p][2]); - resFile[i].data = getResource(Prizes[p][0], Prizes[p][1]); - mdl = resFile[i].GetResMdl(Prizes[p][2]); - pModel[i].setup(mdl, &allocator, 0x224, 1, 0); - SetupTextures_Item(&pModel[i], 0); // 800B43D0 - - anmChr = resFile[i].GetResAnmChr("wait2"); - pAnim[i].setup(mdl, anmChr, &allocator, 0); - // pAnim[i].bind(&pModel[i], anmChr, 1); - // pModel[i].bindAnim(&pAnim[i], 0.0); - pAnim[i].setUpdateRate(1.0); - - prizePos[i] = (Vec){ pos.x, pos.y, pos.z }; - prizeScale[i] = (Vec){ 5.0, 5.0, 5.0 }; - } - - allocator.unlink(); - // Create and prepare the blocks + S16Vec rot = (S16Vec){0,0,0}; float x = pos.x; float y = pos.y - 40.0; float z = pos.z; - S16Vec rot = (S16Vec){0,0,0}; - Cblock = (dSongBlock*)create(WM_KILLER, 1, &(Vec){x-96.0, y, z}, &rot, 0); - Dblock = (dSongBlock*)create(WM_KILLER, 2, &(Vec){x-64.0, y, z}, &rot, 0); - Eblock = (dSongBlock*)create(WM_KILLER, 3, &(Vec){x-32.0, y, z}, &rot, 0); - Fblock = (dSongBlock*)create(WM_KILLER, 4, &(Vec){x , y, z}, &rot, 0); - Gblock = (dSongBlock*)create(WM_KILLER, 5, &(Vec){x+32.0, y, z}, &rot, 0); - Ablock = (dSongBlock*)create(WM_KILLER, 6, &(Vec){x+64.0, y, z}, &rot, 0); - Bblock = (dSongBlock*)create(WM_KILLER, 7, &(Vec){x+96.0, y, z}, &rot, 0); + // for (int i = 0; i < 7; i++) { + // SongBlocks[i] = (dSongBlock*)create(WM_KILLER, i+1, &(Vec){x-96.0+(32.0*i), y, z}, &rot, 0); + // } + + SBa = (dSongBlock*)create(WM_KILLER, 1, &(Vec){x-96.0+(32.0*0), y, z}, &rot, 0); + SBb = (dSongBlock*)create(WM_KILLER, 2, &(Vec){x-96.0+(32.0*1), y, z}, &rot, 0); + SBc = (dSongBlock*)create(WM_KILLER, 3, &(Vec){x-96.0+(32.0*2), y, z}, &rot, 0); + SBd = (dSongBlock*)create(WM_KILLER, 4, &(Vec){x-96.0+(32.0*3), y, z}, &rot, 0); + SBe = (dSongBlock*)create(WM_KILLER, 5, &(Vec){x-96.0+(32.0*4), y, z}, &rot, 0); + SBf = (dSongBlock*)create(WM_KILLER, 6, &(Vec){x-96.0+(32.0*5), y, z}, &rot, 0); + SBg = (dSongBlock*)create(WM_KILLER, 7, &(Vec){x-96.0+(32.0*6), y, z}, &rot, 0); // // Trigger the intro state // state.setState(&StateID_Intro); - isResponding = 0; - OSReport("Is now responding: %d", isResponding); - OSReport("Daddy is at: %x", this); return true; } @@ -354,35 +337,10 @@ int dSingAlong::onExecute() { return true; } -int dSingAlong::onDraw() { - - if (chorus == -1) { return true; } - - for (int i = 0; i < (chorus + 1); i++) { - matrix.translation(prizePos[i].x, prizePos[i].y, prizePos[i].z); - matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); - - pModel[i].setDrawMatrix(matrix); - - pModel[i].setScale(&prizeScale[i]); - - // OSReport("Calc World"); - // pModel[i].calcWorld(false); - - // OSReport("Schedule"); - // pModel[i].scheduleForDrawing(); - - // if (pAnim[i].isAnimationDone()) { - // pAnim[i].setCurrentFrame(0.0); } - - // OSReport("vf1C"); - // pModel[i]._vf1C(); - } - - return true; -} +int dSingAlong::onDraw() { return true; } -int dSingAlong::onDelete() { +int dSingAlong::onDelete() { + instance = 0; return 1; } @@ -396,19 +354,19 @@ void dSingAlong::RegisterNote(int note) { OSReport("State was checked"); if (note == Songs[song][chorus][currentNote][0]) { + PlaySoundAsync(this, Notes[Songs[song][chorus][currentNote][0]-1]); OSReport("Note was correct"); - currentNote += 1; } else { OSReport("Player failed"); + PlaySound(this, SE_MG_CMN_WIN_CLOSE); isResponding = 0; state.setState(&StateID_Failure); } } } - /*****************************************************************************/ // Intro CREATE_STATE(dSingAlong, Intro); @@ -422,28 +380,11 @@ void dSingAlong::executeState_Intro() { CREATE_STATE(dSingAlong, Prize); void dSingAlong::beginState_Prize() { - this->timer = 0; - - if (chorus != 0) { - this->timer = 120; - } - - Xkey_count = 2; - Ykey_count = 2; - Skey_count = 2; - - // /* keysX[i] = { frame, value, slope }; */ - keysX[0] = (HermiteKey){ 0.0, pos.x, 0.8 }; - keysY[0] = (HermiteKey){ 0.0, pos.y, 0.8 }; - keysS[0] = (HermiteKey){ 0.0, 5.0, 0.8 }; - - keysX[1] = (HermiteKey){ 60.0, pos.x + (30.0 * (chorus + 1)) - 320.0, 0.8 }; - keysY[1] = (HermiteKey){ 60.0, pos.y - 80.0, 0.8 }; - keysS[1] = (HermiteKey){ 60.0, 1.0, 0.8 }; + this->timer = 120; } void dSingAlong::executeState_Prize() { - if (timer == 120) { // Play a nice success sound, and wait a second + if ((timer == 120) && (chorus >= 0)) { // Play a nice success sound, and wait a second PlaySound(this, SE_MG_IH_PAIR_OK); // SE_MG_IH_NICE or SE_MG_UH_NICE int p; @@ -451,21 +392,24 @@ void dSingAlong::executeState_Prize() { this->Powerups[p] += 1; } - if (timer < 60 && timer >= 0) { // Move last time's model to the corner. - float modX = GetHermiteCurveValue(60.0 - timer, keysX, Xkey_count); - float modY = GetHermiteCurveValue(60.0 - timer, keysY, Ykey_count); - float modS = GetHermiteCurveValue(60.0 - timer, keysS, Skey_count); - - - prizePos[chorus] = (Vec){ modX, modY, prizePos[chorus].z }; - prizeScale[chorus] = (Vec){ modS, modS, modS }; + if ((timer == 60) && (chorus >= 0)) { + OSReport("Switching PrizeModel States"); + PrizeModel->doStateChange(&dSongPrize::StateID_Shrink); } if (timer == 0) { chorus += 1; - SpawnEffect("Wm_en_blockcloud", 0, &(Vec){pos.x, pos.y, pos.z+500.0}, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}); + if (chorus == 4) { + state.setState(&StateID_Win); + return; + } + + SpawnEffect("Wm_en_blockcloud", 0, &(Vec){pos.x, pos.y+32.0, pos.z+500.0}, &(S16Vec){0,0,0}, &(Vec){1.5, 1.5, 1.5}); PlaySound(this, SE_OBJ_ITEM_APPEAR); // SE_OBJ_GOOD_ITEM_APPEAR + + OSReport("Making the prize model"); + PrizeModel = (dSongPrize*)create(WM_SINKSHIP, chorus + (prize << 16), &pos, &rot, 0); } if (timer == -90) { @@ -521,9 +465,6 @@ void dSingAlong::executeState_Response() { isResponding = 0; OSReport("Switching to some other mode: %d", isResponding); if (chorus == 3) { - state.setState(&StateID_Win); - } - else { state.setState(&StateID_Prize); } } @@ -535,13 +476,15 @@ CREATE_STATE(dSingAlong, Failure); void dSingAlong::beginState_Failure() { this->timer = 0; - - PlaySound(this, SE_MG_CMN_WIN_CLOSE); } void dSingAlong::executeState_Failure() { + if (timer == 60) { + PlaySound(this, SE_MG_IH_NOPAIR_NG); + } + if (timer == 240) { this->addPowerups(); - ExitStage(3, 0, 0, 4); + ExitStage(WORLD_MAP, 0, BEAT_LEVEL, MARIO_WIPE); } timer += 1; } @@ -558,7 +501,7 @@ void dSingAlong::beginState_Win() { void dSingAlong::executeState_Win() { if (timer == 240) { this->addPowerups(); - ExitStage(3, 0, 0, 4); + ExitStage(WORLD_MAP, 0, BEAT_LEVEL, MARIO_WIPE); } timer += 1; } @@ -609,12 +552,10 @@ public: mHeapAllocator_c allocator; nw4r::g3d::ResFile resFile; - m3d::mdl_c bodyModel; - m3d::anmChr_c glow; StageActorLight light; - mHeapAllocator_c allocator2; + mHeapAllocator_c allocatorB; int note; @@ -649,17 +590,10 @@ int dSongBlock::onCreate() { nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("light_block"); bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_MapObj(&bodyModel, 0); // 800B42B0 - - // Animation Assignment - nw4r::g3d::ResAnmChr anmChr = this->resFile.GetResAnmChr("light_block"); - this->glow.setup(mdl, anmChr, &this->allocator, 0); - glow.bind(&bodyModel, anmChr, 1); - bodyModel.bindAnim(&glow, 0.0); - glow.setUpdateRate(1.0); allocator.unlink(); - // light.init(&allocator2, 2); + // light.init(&allocatorB, 2); // Block Physics @@ -687,13 +621,11 @@ int dSongBlock::onCreate() { return true; } - int dSongBlock::onDelete() { physics.removeFromList(); return true; } - int dSongBlock::onExecute() { acState.execute(); physics.update(); @@ -714,17 +646,12 @@ int dSongBlock::onExecute() { return true; } - int dSongBlock::beforeDraw() { // light.draw(); return dStageActor_c::beforeDraw(); } int dSongBlock::onDraw() { - - // tile.x = pos.x - 8; - // tile.y = -(16 + pos.y); - matrix.translation(pos.x, pos.y+8.0, pos.z); matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); @@ -737,15 +664,13 @@ int dSongBlock::onDraw() { return true; } - void dSongBlock::blockWasHit(bool isDown) { pos.y = initialY; - PlaySoundAsync(this, Notes[this->note-1]); - // Play an effect? - OSReport("Note is: %d", this->note); + SpawnEffect("Wm_en_vshit_ring", 0, &(Vec){pos.x, pos.y+8.0, pos.z-100.0}, &(S16Vec){0,0,0}, &(Vec){1.0, 1.0, 1.0}); + SpawnEffect("Wm_ob_keyget02_lighit", 0, &(Vec){pos.x, pos.y+8.0, pos.z-100.0}, &(S16Vec){0,0,0}, &(Vec){0.5, 0.5, 0.5}); + dSingAlong::instance->RegisterNote(this->note); - OSReport("Note successfully registered"); physics.setup(this, &physicsInfo, 3, currentLayerID); physics.addToList(); @@ -753,23 +678,12 @@ void dSongBlock::blockWasHit(bool isDown) { doStateChange(&StateID_Wait); } - void dSongBlock::calledWhenUpMoveExecutes() { - this->bodyModel._vf1C(); - - if (this->glow.isAnimationDone()) { - this->glow.setCurrentFrame(0.0); } - if (initialY >= pos.y) blockWasHit(false); } void dSongBlock::calledWhenDownMoveExecutes() { - this->bodyModel._vf1C(); - - if (this->glow.isAnimationDone()) { - this->glow.setCurrentFrame(0.0); } - if (initialY <= pos.y) blockWasHit(true); } |