diff options
author | Stephen Simpson <megazig@gmail.com> | 2011-10-10 22:58:18 -0500 |
---|---|---|
committer | Stephen Simpson <megazig@gmail.com> | 2011-10-10 22:58:18 -0500 |
commit | b0a9caf3826730be56c57d76abc1a689e104357b (patch) | |
tree | d555723484d2e3b71fad12c9381ec5200f930043 | |
parent | b08cbcc96ec0dcb30858136e799491d5b0cbafb2 (diff) | |
download | kamek-b0a9caf3826730be56c57d76abc1a689e104357b.tar.gz kamek-b0a9caf3826730be56c57d76abc1a689e104357b.zip |
replaced all the variations of NearestPlayer from different bosses
fixed case issue for spritetex.yaml
Diffstat (limited to '')
-rw-r--r-- | spritetex.yaml | 2 | ||||
-rw-r--r-- | src/bossFuzzyBear.cpp | 56 | ||||
-rwxr-xr-x | src/mrsun.cpp | 53 | ||||
-rw-r--r-- | src/player.cpp | 2 |
4 files changed, 7 insertions, 106 deletions
diff --git a/spritetex.yaml b/spritetex.yaml index 2b30bbb..3377a9d 100644 --- a/spritetex.yaml +++ b/spritetex.yaml @@ -1,5 +1,5 @@ --- -source_files: [../src/spritetex.s] +source_files: [../src/spritetex.S] hooks: # - name: TEX_WoodBox # type: branch_insn diff --git a/src/bossFuzzyBear.cpp b/src/bossFuzzyBear.cpp index 65e6ab6..c218f6d 100644 --- a/src/bossFuzzyBear.cpp +++ b/src/bossFuzzyBear.cpp @@ -3,6 +3,8 @@ #include <g3dhax.h> #include <sfx.h> +#include "player.h" + class daFuzzyBear_c : public dEn_c { int onCreate(); int onDelete(); @@ -68,9 +70,6 @@ extern "C" dStageActor_c *CreateActor(u16 classID, int settings, Vec pos, char r extern "C" u8 dSprite_c__getXDirectionOfFurthestPlayerRelativeToVEC3(daFuzzyBear_c *, Vec pos); extern "C" dStageActor_c *GetSpecificPlayerActor(int number); -int NearestPlayerF(daFuzzyBear_c *Sprite); -float PlayertoSpriteDistanceF(Vec sprite, Vec player); - CREATE_STATE(daFuzzyBear_c, Grow); CREATE_STATE(daFuzzyBear_c, Bounce); @@ -242,7 +241,7 @@ int daFuzzyBear_c::onExecute() { updateModelMatrices(); if (this->aPhysics.result1 == 1) { - char PlayerID = NearestPlayerF(this); + char PlayerID = NearestPlayer(this); dStageActor_c *Player = GetSpecificPlayerActor(PlayerID); this->_vf220(Player); @@ -251,55 +250,6 @@ int daFuzzyBear_c::onExecute() { return true; } -int NearestPlayerF(daFuzzyBear_c *Sprite) { - float pfloat[] = { 0.0, 0.0, 0.0, 0.0 }; - float max = 1000000.0; - char maxPlayer = 5; - int i; - OSReport("FINDING NEAREST PLAYER"); - - for (i=0; i<4; i++) { - OSReport("K, let's check out Player %d", i); - dStageActor_c *Player = GetSpecificPlayerActor(i); - if (Player != 0) { - OSReport("Player %d exists", i); - pfloat[i] = PlayertoSpriteDistanceF(Sprite->pos, Player->pos); - - OSReport("if %f > %f", pfloat[i], max); - if (pfloat[i] < max) { - max = pfloat[i]; - maxPlayer = i; - OSReport("MaxPlayer now %d", i); - } - } - } - - OSReport("MaxPlayer finalized at %d", maxPlayer); - - return maxPlayer; -} - -float PlayertoSpriteDistanceF(Vec sprite, Vec player) { - float x = sprite.x - player.x; - float y = sprite.y - player.y; - - float x2 = x * x; - float y2 = y * y; - - float returnval = x2+y2; - - OSReport("X: (%f - %f)^2 = %f", sprite.x, player.x, x2); - OSReport("Y: (%f - %f)^2 = %f", sprite.y, player.y, y2); - - - if (returnval < 0) { returnval = -returnval; } - - OSReport("Return: %f", returnval); - - return returnval; -} - - int daFuzzyBear_c::onDraw() { bodyModel.scheduleForDrawing(); diff --git a/src/mrsun.cpp b/src/mrsun.cpp index df4d1ac..8fb4524 100755 --- a/src/mrsun.cpp +++ b/src/mrsun.cpp @@ -2,6 +2,8 @@ #include <game.h> #include <g3dhax.h> +#include "player.h" + class daMrSun_c : public dEn_c { int onCreate(); int onDelete(); @@ -76,9 +78,6 @@ extern "C" dStageActor_c *GetSpecificPlayerActor(int number); extern "C" void *PlaySound(daMrSun_c *, int soundID); -int NearestPlayer(daMrSun_c *Sprite); -float PlayertoSpriteDistance(Vec sprite, Vec player); - CREATE_STATE(daMrSun_c, Follow); CREATE_STATE(daMrSun_c, Swoop); CREATE_STATE(daMrSun_c, Spiral); @@ -292,54 +291,6 @@ int daMrSun_c::onExecute() { return true; } -int NearestPlayer(daMrSun_c *Sprite) { - float pfloat[] = { 0.0, 0.0, 0.0, 0.0 }; - float max = 1000000.0; - char maxPlayer = 5; - int i; - OSReport("FINDING NEAREST PLAYER"); - - for (i=0; i<4; i++) { - OSReport("K, let's check out Player %d", i); - dStageActor_c *Player = GetSpecificPlayerActor(i); - if (Player != 0) { - OSReport("Player %d exists", i); - pfloat[i] = PlayertoSpriteDistance(Sprite->pos, Player->pos); - - OSReport("if %f > %f", pfloat[i], max); - if (pfloat[i] < max) { - max = pfloat[i]; - maxPlayer = i; - OSReport("MaxPlayer now %d", i); - } - } - } - - OSReport("MaxPlayer finalized at %d", i); - - return maxPlayer; -} - -float PlayertoSpriteDistance(Vec sprite, Vec player) { - float x = sprite.x - player.x; - float y = sprite.y - player.y; - - float x2 = x * x; - float y2 = y * y; - - float returnval = x2+y2; - - OSReport("X: (%f - %f)^2 = %f", sprite.x, player.x, x2); - OSReport("Y: (%f - %f)^2 = %f", sprite.y, player.y, y2); - - - if (returnval < 0) { returnval = -returnval; } - - OSReport("Return: %f", returnval); - - return returnval; -} - int daMrSun_c::onDraw() { bodyModel.scheduleForDrawing(); if (hasGlow) diff --git a/src/player.cpp b/src/player.cpp index ec638d4..e7480fe 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -4,7 +4,7 @@ // Please check return for -1 char NearestPlayer(dStageActor_c* actor) { char nearest = -1; - float current = 3000000.0; + float current = 5000000.0; OSReport("FINDING NEAREST PLAYER\n"); for(char ii = 0; ii < 4; ii++) { |