diff options
author | Colin Noga <Tempus@chronometry.ca> | 2012-07-20 17:49:19 -0500 |
---|---|---|
committer | Colin Noga <Tempus@chronometry.ca> | 2012-07-20 17:49:19 -0500 |
commit | 228e5b26f02321bf90981879bd9781cbd91ab6a9 (patch) | |
tree | 08ab45981088abe5c5327965920b2f4dbf9e1d76 /src/koopatlas/pathmanager.cpp | |
parent | 2d39f19d92673bb9a8f12a71bbd6d86dd2166237 (diff) | |
download | kamek-228e5b26f02321bf90981879bd9781cbd91ab6a9.tar.gz kamek-228e5b26f02321bf90981879bd9781cbd91ab6a9.zip |
Trying to do the damn jump code
Diffstat (limited to 'src/koopatlas/pathmanager.cpp')
-rw-r--r-- | src/koopatlas/pathmanager.cpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 6cf0750..f33bc7b 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -6,6 +6,8 @@ void dWMPathManager_c::setup() { isMoving = false; + isJumping = false; + timer = 0.0; currentPath = 0; reverseThroughPath = false; @@ -126,29 +128,15 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { SpammyReport("f\n"); daWMPlayer_c *player = daWMPlayer_c::instance; SpammyReport("g %p\n", player); - // path->speed - // wait = 0, - // walk = 1, - // run = 2, - // b_dash2 = 4, - - // jump = 5, - // 2jmp_c_2 = 9, - // 2jumped = 10, - - // tree_climb = 45, - - // swim_wait - // swim_walk = 38, + // Consider adding these as options // wall_walk_l = 60, // wall_walk_r = 61, // hang_walk_l = 65, // hang_walk_r = 66, - // wait, door_walk SpammyReport("h\n"); player->rot.y = direction; player->hasSound = false; @@ -188,18 +176,22 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { case 4: player->startAnimation(jump, 1.0, 1.0, 0.0); MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1); + isJumping = true; break; case 5: player->startAnimation(jump, 1.0, 10.0, 0.0); MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1); + isJumping = true; break; case 6: player->startAnimation(jump, 1.0, 10.0, 0.0); MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1); + isJumping = true; break; case 7: player->startAnimation(jump, 1.0, 10.0, 0.0); MapSoundPlayer(SoundRelatedClass, SE_PLY_JUMP, 1); + isJumping = true; SpawnEffect("Wm_mr_waterwave_out", 0, &player->pos, 0, &player->scale); break; @@ -225,7 +217,6 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { // Others case 12: - OSReport("Swimming"); player->startAnimation(swim_wait, 1.2, 10.0, 0.0); player->hasSound = true; player->hasEffect = true; @@ -233,23 +224,19 @@ void dWMPathManager_c::startMovementTo(dKPPath_s *path) { player->effectName = "Wm_mr_waterswim"; break; case 13: - OSReport("Falling"); player->startAnimation(Tjumped, 2.0, 0.0, 0.0); break; case 14: - OSReport("Dashing"); player->startAnimation(b_dash2, 3.0, 10.0, 0.0); player->hasSound = true; player->soundName = SE_PLY_FOOTNOTE_DIRT; break; case 15: - OSReport("Piping"); player->startAnimation(wait, 2.0, 10.0, 0.0); player->rot.y = 0x0000; MapSoundPlayer(SoundRelatedClass, SE_PLY_DOKAN_IN_OUT, 1); break; case 16: - OSReport("Dooring"); player->startAnimation(wait, 2.0, 10.0, 0.0); player->rot.y = 0x8000; MapSoundPlayer(SoundRelatedClass, SE_OBJ_DOOR_OPEN, 1); @@ -277,8 +264,24 @@ void dWMPathManager_c::moveThroughPath() { daWMPlayer_c *player = daWMPlayer_c::instance; - player->pos.x += move.x; - player->pos.y -= move.y; + if (isJumping) { + float midpoint = (from->y + to->y) / 2; + + keysY[0] = (HermiteKey){ from->y, 0.0, 1.0 }; + keysY[1] = (HermiteKey){ midpoint, 48.0, 0.8 }; + keysY[2] = (HermiteKey){ to->y, 0.0, 1.0 }; + + float modY = GetHermiteCurveValue(player->pos.y, keysY, 3); + OSReport("From: %f to %f, midpoint at: %f, pos at %f, Y mod: %f", from->y, to->y, midpoint, player->pos.y, modY); + + player->pos.x += move.x; + player->pos.y -= move.y; + } + + else { + player->pos.x += move.x; + player->pos.y -= move.y; + } // Check if we've reached the end yet if ( @@ -290,6 +293,9 @@ void dWMPathManager_c::moveThroughPath() { player->pos.x = to->x; player->pos.y = -to->y; + isJumping = false; + timer = 0.0; + SpammyReport("reached path end (%p)\n", to); if (to->type == dKPNode_s::CHANGE) { |