diff options
author | Treeki <treeki@gmail.com> | 2012-11-10 17:15:51 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2012-11-10 17:15:51 +0100 |
commit | a1ca2b30e4f05037d2a0d60b821e2f8699ab8891 (patch) | |
tree | 2d8c5dcb8a0ec1c680e1e9b47d7a4880d6707277 /src/koopatlas/player.cpp | |
parent | 22915e16efa62f3169227f6121326cb5af5315ba (diff) | |
download | kamek-a1ca2b30e4f05037d2a0d60b821e2f8699ab8891.tar.gz kamek-a1ca2b30e4f05037d2a0d60b821e2f8699ab8891.zip |
pushed the very unfinished 4P
Diffstat (limited to 'src/koopatlas/player.cpp')
-rw-r--r-- | src/koopatlas/player.cpp | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp index a3e484a..3a736b4 100644 --- a/src/koopatlas/player.cpp +++ b/src/koopatlas/player.cpp @@ -1,4 +1,5 @@ #include "koopatlas/player.h" +#include "koopatlas/subplayer.h" daWMPlayer_c *daWMPlayer_c::instance; @@ -17,8 +18,6 @@ int daWMPlayer_c::onCreate() { rot = (S16Vec){0x1800,0,0}; scale = (Vec){1.6f,1.6f,1.6f}; - current_param = 0; - hasEffect = false; hasSound = false; step = false; @@ -43,6 +42,38 @@ int daWMPlayer_c::onExecute() { dScKoopatlas_c::instance->pathManager.execute(); + // work out the Z positions first of all + struct ySortThing_s { + float y; int id; + }; + ySortThing_s sorts[4]; + sorts[0].y = pos.y; + sorts[0].id = 0; + for (int i = 1; i < 4; i++) { + sorts[i].y = stateHistory[i * SUBPLAYER_DISTANCE].pos.y; + sorts[i].id = i; + } + + // bubble sort it with an algorithm from wikipedia + bool swapped; + do { + swapped = false; + for (int i = 1; i < 4; i++) { + if (sorts[i-1].y > sorts[i].y) { + ySortThing_s forSwap = sorts[i-1]; + sorts[i-1] = sorts[i]; + sorts[i] = forSwap; + swapped = true; + } + } + } while (swapped); + + // then put together the positions + float chosenZPositions[4]; + for (int i = 0; i < 4; i++) + chosenZPositions[sorts[i].id] = 3100.0f - (i * 25.0f); + pos.z = chosenZPositions[0]; + this->modelHandler->update(); mMtx myMatrix; @@ -70,6 +101,42 @@ int daWMPlayer_c::onExecute() { if (timer > 12) { timer = 0; } } + if (stateHistoryBuilt) { + for (int i = STATE_COUNT - 1; i >= 1; i--) + stateHistory[i] = stateHistory[i - 1]; + } + + state_s *st = &stateHistory[0]; + st->pos = pos; + st->scale = scale; + st->rot = rot; + st->repeatedEffect = (hasEffect ? effectName : 0); + st->nowEffect = nextNowEffect; + st->repeatedSound = (hasSound ? soundName : 0); + st->nowSound = nextNowSound; + st->jumpOffset = jumpOffset; + st->anim = currentAnim; + st->animFrame = currentFrame; + st->animUnk = currentUnk; + st->animUpdateRate = currentUpdateRate; + + if (!stateHistoryBuilt) { + for (int i = 1; i < STATE_COUNT; i++) + stateHistory[i] = stateHistory[0]; + stateHistoryBuilt = true; + } + + nextNowEffect = 0; + nextNowSound = 0; + + for (int i = 0; i < 3; i++) { + daWMSubPlayer_c *sp = dScKoopatlas_c::instance->subPlayer[i]; + + state_s *st = &stateHistory[(i+1) * SUBPLAYER_DISTANCE]; + st->pos.z = chosenZPositions[i+1]; + sp->update(st); + } + return true; } |