diff options
author | Treeki <treeki@gmail.com> | 2012-09-22 23:57:21 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-09-22 23:57:21 +0200 |
commit | 888a7aacf0cc617739e891cb5774ec1da96803ed (patch) | |
tree | 1ad77d72ceb6c8fc4b2677a4d0be883d4fc59c31 | |
parent | 649f1998d02d54344c0b8cd902dea9c770be8656 (diff) | |
download | kamek-888a7aacf0cc617739e891cb5774ec1da96803ed.tar.gz kamek-888a7aacf0cc617739e891cb5774ec1da96803ed.zip |
some badly needed polishing for the map engine
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 50 | ||||
-rw-r--r-- | src/koopatlas/pathmanager.h | 4 |
2 files changed, 43 insertions, 11 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index a80c2b4..300e628 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -11,6 +11,7 @@ void dWMPathManager_c::setup() { timer = 0.0; currentPath = 0; reverseThroughPath = false; + beginWait = 120; pathLayer = dScKoopatlas_c::instance->mapData.pathLayer; @@ -21,6 +22,7 @@ void dWMPathManager_c::setup() { SpammyReport("Unlocking paths\n"); isEnteringLevel = false; + levelStartWait = -1; unlockPaths(); SpammyReport("done\n"); @@ -283,21 +285,44 @@ bool dWMPathManager_c::evaluateUnlockCondition(u8 *&in, SaveBlock *save, int sta void dWMPathManager_c::execute() { + if (beginWait > 0) { + beginWait--; + return; + } + + if (isEnteringLevel) { + if (levelStartWait > 0) { + levelStartWait--; + if (levelStartWait == 0) { + dScKoopatlas_c::instance->startLevel(enteredLevel); + } + } + return; + } + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); if (isMoving) { moveThroughPath(); } else { - if (nowPressed & WPAD_LEFT && canUseExit(currentNode->leftExit)) - startMovementTo(currentNode->leftExit); - else if (nowPressed & WPAD_RIGHT && canUseExit(currentNode->rightExit)) - startMovementTo(currentNode->rightExit); - else if (nowPressed & WPAD_UP && canUseExit(currentNode->upExit)) - startMovementTo(currentNode->upExit); - else if (nowPressed & WPAD_DOWN && canUseExit(currentNode->downExit)) - startMovementTo(currentNode->downExit); + // Left, right, up, down + int pressedDir = -1; + if (nowPressed & WPAD_LEFT) pressedDir = 0; + else if (nowPressed & WPAD_RIGHT) pressedDir = 1; + else if (nowPressed & WPAD_UP) pressedDir = 2; + else if (nowPressed & WPAD_DOWN) pressedDir = 3; else if (nowPressed & WPAD_TWO) activatePoint(); + + if (pressedDir >= 0) { + if (canUseExit(currentNode->exits[pressedDir])) { + startMovementTo(currentNode->exits[pressedDir]); + } else { + // TODO: maybe remove this? got to see how it looks + static u16 directions[] = {-0x4000,0x4000,-0x7FFF,0}; + daWMPlayer_c::instance->rot.y = directions[pressedDir]; + } + } } // handle path fading @@ -590,6 +615,9 @@ void dWMPathManager_c::moveThroughPath() { } void dWMPathManager_c::activatePoint() { + if (levelStartWait >= 0) + return; + if (currentNode->type == dKPNode_s::LEVEL) { int w = currentNode->levelNumber[0] - 1; int l = currentNode->levelNumber[1] - 1; @@ -613,11 +641,11 @@ void dWMPathManager_c::activatePoint() { MapSoundPlayer(SoundRelatedClass, SE_SYS_GAME_START, 1); daWMPlayer_c::instance->startAnimation(170, 1.2, 10.0, 0.0); + daWMPlayer_c::instance->rot.y = 0; isEnteringLevel = true; - - dLevelInfo_c::entry_s *level = dScKoopatlas_c::instance->levelInfo.search(w, l); - dScKoopatlas_c::instance->startLevel(level); + levelStartWait = 40; + enteredLevel = dScKoopatlas_c::instance->levelInfo.search(w, l); } } diff --git a/src/koopatlas/pathmanager.h b/src/koopatlas/pathmanager.h index d22168b..6f2e763 100644 --- a/src/koopatlas/pathmanager.h +++ b/src/koopatlas/pathmanager.h @@ -19,6 +19,8 @@ class dWMPathManager_c { return (path != 0) && (path->isAvailable); } + int beginWait; + void startMovementTo(dKPPath_s *path); void moveThroughPath(); void activatePoint(); @@ -53,6 +55,8 @@ class dWMPathManager_c { bool evaluateUnlockCondition(u8 *&in, SaveBlock *save, int stack); bool isEnteringLevel; + int levelStartWait; + dLevelInfo_c::entry_s *enteredLevel; }; #endif |