diff options
author | Treeki <treeki@gmail.com> | 2013-05-05 23:07:33 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2013-05-05 23:07:33 +0200 |
commit | 5ce91e3cd72989860e3f2a34f460a5b3c09388a9 (patch) | |
tree | 521e84eb6015a514d9657d078d1793d6c246257f /src | |
parent | 390b1fcc3c7fc55882fe8fc9f2b7cc1afc455824 (diff) | |
download | kamek-5ce91e3cd72989860e3f2a34f460a5b3c09388a9.tar.gz kamek-5ce91e3cd72989860e3f2a34f460a5b3c09388a9.zip |
add continuous movement to map engine
Diffstat (limited to '')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index c35ee4a..5acac0c 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -30,6 +30,14 @@ void ResetAllCompletionCandidates() { CanFinishEverything = false; } +int getPressedDir(int buttons) { + if (buttons & WPAD_LEFT) return 0; + else if (buttons & WPAD_RIGHT) return 1; + else if (buttons & WPAD_UP) return 2; + else if (buttons & WPAD_DOWN) return 3; + return -1; +} + void dWMPathManager_c::setup() { dScKoopatlas_c *wm = dScKoopatlas_c::instance; @@ -971,11 +979,7 @@ void dWMPathManager_c::execute() { int nowPressed = Remocon_GetPressed(GetActiveRemocon()); // 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; + int pressedDir = getPressedDir(nowPressed); if (isMoving) { moveThroughPath(pressedDir); @@ -1435,7 +1439,7 @@ void dWMPathManager_c::moveThroughPath(int pressedDir) { } else if (reallyStop) { // Stop here - player->startAnimation(wait_select, 1.2, 10.0, 0.0); + bool movingAgain = false; player->hasEffect = false; player->hasSound = false; @@ -1448,6 +1452,25 @@ void dWMPathManager_c::moveThroughPath(int pressedDir) { save->current_path_node = pathLayer->findNodeID(to); if (!calledEnteredNode && dWMHud_c::instance) dWMHud_c::instance->enteredNode(); + + // Should we continue here? (Requested by Jason) + int held = Remocon_GetButtons(GetActiveRemocon()); + int pressedDir = getPressedDir(held); + if (pressedDir >= 0) { + // Use an exit if possible + if (canUseExit(currentNode->exits[pressedDir])) { + startMovementTo(currentNode->exits[pressedDir]); + movingAgain = true; + } else { + // TODO: maybe remove this? got to see how it looks + static u16 directions[] = {-0x4000,0x4000,-0x7FFF,0}; + daWMPlayer_c::instance->setTargetRotY(directions[pressedDir]); + } + } + + if (!movingAgain) + player->startAnimation(wait_select, 1.2, 10.0, 0.0); + } else { startMovementTo(to->getOppositeAvailableExitTo(currentPath)); SpammyReport("passthrough node, continuing to next path\n"); |