1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-07-03 06:24:32 +00:00

Some fixes (...)

- Get colliding hair segment
- drop AnimatedSprite & Interpolator classes
- repair entity_setAutoSkeletalUpdate()
- remove some old code
This commit is contained in:
fgenesis 2012-12-13 18:45:07 +01:00
parent 5d74665323
commit b242d80c75
10 changed files with 38 additions and 129 deletions

View file

@ -4584,7 +4584,6 @@ Avatar::Avatar() : Entity(), ActionMapper()
this->pushingOffWallEffect = 0; this->pushingOffWallEffect = 0;
lockToWallFallTimer = 0; lockToWallFallTimer = 0;
swimming = false; swimming = false;
dodgeDelay = 0;
charging = false; charging = false;
bursting = false; bursting = false;
animatedBurst = false; animatedBurst = false;
@ -4595,8 +4594,6 @@ Avatar::Avatar() : Entity(), ActionMapper()
splashDelay = 0; splashDelay = 0;
avatar = this; avatar = this;
frame = 0;
particleDelay = 0; particleDelay = 0;
swimming = false; swimming = false;
@ -5006,44 +5003,6 @@ void Avatar::setActiveSpell(Spells spell)
} }
*/ */
void Avatar::dodge(std::string dir)
{
if (bursting) return;
if (!canMove) return;
if (dodgeDelay == 0)
{
Vector mov;
if (dir == "right")
mov = Vector(1,0);
else if (dir == "left")
mov = Vector(-1, 0);
else if (dir == "down")
mov = Vector(0, 1);
else if (dir == "up")
mov = Vector(0, -1);
Vector lastPosition = position;
//position += mov * 80;
dodgeVec = mov * 8000;
vel += mov * vars->maxDodgeSpeed;
//dodgeEffectTimer = 0.125;
state.dodgeEffectTimer.start(/*0.125*/vars->dodgeTime);
/*
float vlen = vel.getLength2D();
mov |= 500;
vel += mov;
*/
/*
if (dsq->game->collideCircleWithGrid(position, 24))
{
position = lastPosition;
}
*/
}
}
void Avatar::startBackFlip() void Avatar::startBackFlip()
{ {
if (boneLock.on) return; if (boneLock.on) return;
@ -5284,29 +5243,6 @@ void Avatar::startWallBurst(bool useCursor)
} }
} }
void Avatar::doDodgeInput(const std::string &action, int s)
{
if (s)
{
if (tapped.empty())
{
tapped = action;
state.tapTimer.start(0.25);
}
else if (tapped == action)
{
if (state.tapTimer.isActive())
dodge(action);
tapped = "";
dodgeDelay = 1.0;
}
else
{
tapped = "";
}
}
}
Vector Avatar::getKeyDir() Vector Avatar::getKeyDir()
{ {
Vector dir; Vector dir;
@ -5983,13 +5919,7 @@ int Avatar::getBeamWidth()
void Avatar::onEnterState(int action) void Avatar::onEnterState(int action)
{ {
Entity::onEnterState(action); Entity::onEnterState(action);
if (action == STATE_TRANSFORM) if (action == STATE_PUSH)
{
animator.stop();
frame = 0;
animate(anim_fish);
}
else if (action == STATE_PUSH)
{ {
state.lockedToWall = false; state.lockedToWall = false;
state.crawlingOnWall = false; state.crawlingOnWall = false;
@ -7983,10 +7913,6 @@ void Avatar::onUpdate(float dt)
{ {
} }
if (state.tapTimer.updateCheck(dt))
{
tapped = "";
}
if (pushingOffWallEffect > 0) if (pushingOffWallEffect > 0)
{ {
pushingOffWallEffect -= dt; pushingOffWallEffect -= dt;
@ -8035,14 +7961,6 @@ void Avatar::onUpdate(float dt)
} }
} }
*/ */
if (dodgeDelay > 0)
{
dodgeDelay -= dt;
if (dodgeDelay <= 0)
{
dodgeDelay = 0;
}
}
if (text) if (text)
{ {

View file

@ -127,7 +127,6 @@ public:
float shotDelay; float shotDelay;
//Timer shockTimer; //Timer shockTimer;
Timer useItemDelay; Timer useItemDelay;
Timer tapTimer;
Timer lockToWallDelay; Timer lockToWallDelay;
float spellCharge; float spellCharge;
bool lockedToWall; bool lockedToWall;
@ -151,8 +150,6 @@ public:
virtual ~Avatar(); virtual ~Avatar();
void destroy(); void destroy();
void action(int actionID, int state); void action(int actionID, int state);
// anim data
AnimData anim_swim, anim_stopTransition, anim_idle, anim_idle2, anim_burst, anim_fish;
AvatarState state; AvatarState state;
void setIgnoreInputDelay(float delay) void setIgnoreInputDelay(float delay)
{ {
@ -518,19 +515,10 @@ protected:
bool charging; bool charging;
AnimData tongueAnim;
//Quad *chargeGraphic;
Vector lastPush; Vector lastPush;
std::string tapped;
float dodgeDelay;
float pushingOffWallEffect; float pushingOffWallEffect;
float lockToWallFallTimer; float lockToWallFallTimer;
void dodge(std::string dir);
void doDodgeInput(const std::string &action, int state);
Vector dodgeVec; Vector dodgeVec;
Vector wallPushVec, wallTurnVec; Vector wallPushVec, wallTurnVec;

View file

@ -501,9 +501,9 @@ void Entity::followPath(Path *p, int speedType, int dir, bool deleteOnEnd)
position.data->path.addPathNode(pn.position, float(i/float(p->nodes.size()))); position.data->path.addPathNode(pn.position, float(i/float(p->nodes.size())));
} }
} }
debugLog("Calculating Time"); //debugLog("Calculating Time");
float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType); float time = position.data->path.getLength()/(float)dsq->continuity.getSpeedType(speedType);
debugLog("Starting"); //debugLog("Starting");
position.data->path.getPathNode(0)->value = position; position.data->path.getPathNode(0)->value = position;
position.startPath(time);//, 1.0f/2.0f); position.startPath(time);//, 1.0f/2.0f);
} }
@ -1266,7 +1266,7 @@ void Entity::update(float dt)
//skeletalSprite.setFreeze(true); //skeletalSprite.setFreeze(true);
if (frozenTimer == 0 || getState() == STATE_PUSH) if (frozenTimer == 0 || getState() == STATE_PUSH)
AnimatedSprite::update(dt); Quad::update(dt);
onAlwaysUpdate(dt); onAlwaysUpdate(dt);
// always, always update: // always, always update:
@ -1873,7 +1873,7 @@ void Entity::onUpdate(float dt)
} }
} }
AnimatedSprite::onUpdate(dt); Quad::onUpdate(dt);
Vector v = position - lastPos; Vector v = position - lastPos;
lastMove = v; lastMove = v;
@ -2971,7 +2971,7 @@ void Entity::render()
blurShader.bind(); blurShader.bind();
set = true; set = true;
} }
AnimatedSprite::render(); Quad::render();
//if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating()) //if (beautyFlip && blurShader.isLoaded() && flipScale.isInterpolating())
if (set) if (set)
blurShader.unbind(); blurShader.unbind();

View file

@ -21,7 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef ENTITY_H #ifndef ENTITY_H
#define ENTITY_H #define ENTITY_H
#include "../BBGE/AnimatedSprite.h"
#include "../BBGE/StateMachine.h" #include "../BBGE/StateMachine.h"
#include "../ExternalLibs/tinyxml.h" #include "../ExternalLibs/tinyxml.h"
#include "../BBGE/SkeletalSprite.h" #include "../BBGE/SkeletalSprite.h"
@ -195,7 +194,7 @@ enum BounceType
BOUNCE_REAL = 1 BOUNCE_REAL = 1
}; };
class Entity : public AnimatedSprite, public StateMachine class Entity : public Quad, public StateMachine
{ {
public: public:
Entity(); Entity();
@ -592,7 +591,7 @@ protected:
void updateBoneLock(); void updateBoneLock();
int pushMaxSpeed; int pushMaxSpeed;
std::string currentAnim;
protected: protected:

View file

@ -8346,26 +8346,25 @@ bool Game::collideCircleVsCircle(Entity *a, Entity *b)
return (a->position - b->position).isLength2DIn(a->collideRadius + b->collideRadius); return (a->position - b->position).isLength2DIn(a->collideRadius + b->collideRadius);
} }
bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc) bool Game::collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc, int *colSegment)
{ {
if (perc == 0) if (perc == 0)
perc = 1; perc = 1;
bool c = false; bool c = false;
if (a->hair) if (a && a->hair)
{ {
if (a) if (num == 0)
num = a->hair->hairNodes.size();
// HACK: minus 2
for (int i = 0; i < num; i++)
{ {
if (num == 0) // + a->hair->position
num = a->hair->hairNodes.size(); c = ((a->hair->hairNodes[i].position) - pos2).isLength2DIn(a->hair->hairWidth*perc + radius);
// HACK: minus 2 if (c)
for (int i = 0; i < num; i++)
{ {
// + a->hair->position if (colSegment)
c = ((a->hair->hairNodes[i].position) - pos2).isLength2DIn(a->hair->hairWidth*perc + radius); *colSegment = i;
if (c) return true;
{
return true;
}
} }
} }
} }

View file

@ -677,7 +677,7 @@ public:
bool collideBoxWithGrid(const Vector& position, int w, int h); bool collideBoxWithGrid(const Vector& position, int w, int h);
bool collideCircleWithGrid(const Vector& position, int r); bool collideCircleWithGrid(const Vector& position, int r);
bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc=0); bool collideHairVsCircle(Entity *a, int num, const Vector &pos2, int radius, float perc=0, int *colSegment=0);
bool collideCircleVsCircle(Entity *a, Entity *b); bool collideCircleVsCircle(Entity *a, Entity *b);
Bone *collideSkeletalVsCircle(Entity *skeletal, Entity *circle); Bone *collideSkeletalVsCircle(Entity *skeletal, Entity *circle);

View file

@ -4140,9 +4140,16 @@ luaFunc(entity_collideHairVsCircle)
int num = lua_tonumber(L, 3); int num = lua_tonumber(L, 3);
// perc: percent of hairWidth to use as collide radius // perc: percent of hairWidth to use as collide radius
float perc = lua_tonumber(L, 4); float perc = lua_tonumber(L, 4);
col = dsq->game->collideHairVsCircle(e, num, e2->position, e2->collideRadius, perc); int colSegment;
col = dsq->game->collideHairVsCircle(e, num, e2->position, e2->collideRadius, perc, &colSegment);
if(col)
{
lua_pushboolean(L, true);
lua_pushinteger(L, colSegment);
return 2;
}
} }
luaReturnBool(col); luaReturnBool(false);
} }
luaFunc(entity_collideSkeletalVsCircleForListByName) luaFunc(entity_collideSkeletalVsCircleForListByName)
@ -4276,7 +4283,12 @@ luaFunc(entity_updateSkeletal)
{ {
Entity *e = entity(L); Entity *e = entity(L);
if (e) if (e)
{
bool oldIgnore = e->skeletalSprite.ignoreUpdate;
e->skeletalSprite.ignoreUpdate = false;
e->skeletalSprite.update(lua_tonumber(L, 2)); e->skeletalSprite.update(lua_tonumber(L, 2));
e->skeletalSprite.ignoreUpdate = oldIgnore;
}
luaReturnNil(); luaReturnNil();
} }

View file

@ -30,7 +30,6 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
{ {
addType(SCO_SCRIPTED_ENTITY); addType(SCO_SCRIPTED_ENTITY);
crushDelay = 0; crushDelay = 0;
autoSkeletalSpriteUpdate = true;
script = 0; script = 0;
songNoteFunction = songNoteDoneFunction = true; songNoteFunction = songNoteDoneFunction = true;
addChild(&pullEmitter, PM_STATIC); addChild(&pullEmitter, PM_STATIC);
@ -83,7 +82,7 @@ ScriptedEntity::ScriptedEntity(const std::string &scriptName, Vector position, E
void ScriptedEntity::setAutoSkeletalUpdate(bool v) void ScriptedEntity::setAutoSkeletalUpdate(bool v)
{ {
autoSkeletalSpriteUpdate = v; skeletalSprite.ignoreUpdate = !v;
} }
void ScriptedEntity::message(const std::string &msg, int v) void ScriptedEntity::message(const std::string &msg, int v)
@ -640,13 +639,8 @@ void ScriptedEntity::onUpdate(float dt)
} }
*/ */
if (!autoSkeletalSpriteUpdate)
skeletalSprite.ignoreUpdate = true;
CollideEntity::onUpdate(dt); CollideEntity::onUpdate(dt);
if (!autoSkeletalSpriteUpdate)
skeletalSprite.ignoreUpdate = false;
//updateStrands(dt); //updateStrands(dt);
if (becomeSolidDelay) if (becomeSolidDelay)

View file

@ -93,7 +93,6 @@ protected:
void onDieEaten(); void onDieEaten();
void luaDebugMsg(const std::string &func, const std::string &msg); void luaDebugMsg(const std::string &func, const std::string &msg);
float crushDelay; float crushDelay;
bool autoSkeletalSpriteUpdate;
int beforePullMaxSpeed; int beforePullMaxSpeed;
bool songNoteFunction, preUpdateFunc; bool songNoteFunction, preUpdateFunc;
bool songNoteDoneFunction; bool songNoteDoneFunction;

View file

@ -373,7 +373,6 @@ SET(BBGE_SRCS
${BBGEDIR}/ActionMapper.cpp ${BBGEDIR}/ActionMapper.cpp
${BBGEDIR}/ActionSet.cpp ${BBGEDIR}/ActionSet.cpp
${BBGEDIR}/AfterEffect.cpp ${BBGEDIR}/AfterEffect.cpp
${BBGEDIR}/AnimatedSprite.cpp
${BBGEDIR}/Base.cpp ${BBGEDIR}/Base.cpp
${BBGEDIR}/BitmapFont.cpp ${BBGEDIR}/BitmapFont.cpp
${BBGEDIR}/Collision.cpp ${BBGEDIR}/Collision.cpp
@ -387,7 +386,6 @@ SET(BBGE_SRCS
${BBGEDIR}/Flags.cpp ${BBGEDIR}/Flags.cpp
${BBGEDIR}/FrameBuffer.cpp ${BBGEDIR}/FrameBuffer.cpp
${BBGEDIR}/Gradient.cpp ${BBGEDIR}/Gradient.cpp
${BBGEDIR}/Interpolator.cpp
${BBGEDIR}/Joystick.cpp ${BBGEDIR}/Joystick.cpp
${BBGEDIR}/LensFlare.cpp ${BBGEDIR}/LensFlare.cpp
${BBGEDIR}/Localization.cpp ${BBGEDIR}/Localization.cpp
@ -460,12 +458,14 @@ SET(PNG_SRCS
# Apparently not used at the moment. Listed here just for completeness. # Apparently not used at the moment. Listed here just for completeness.
SET(BBGE_SRCS_UNUSED SET(BBGE_SRCS_UNUSED
${BBGEDIR}/AnimatedSprite.cpp
${BBGEDIR}/BloomEffect.cpp ${BBGEDIR}/BloomEffect.cpp
${BBGEDIR}/CShim.cpp ${BBGEDIR}/CShim.cpp
${BBGEDIR}/Cutscene.cpp ${BBGEDIR}/Cutscene.cpp
${BBGEDIR}/Datafile.cpp ${BBGEDIR}/Datafile.cpp
${BBGEDIR}/DFSprite.cpp ${BBGEDIR}/DFSprite.cpp
${BBGEDIR}/FileVars.cpp ${BBGEDIR}/FileVars.cpp
${BBGEDIR}/Interpolator.cpp
${BBGEDIR}/Light.cpp ${BBGEDIR}/Light.cpp
${BBGEDIR}/LightCone.cpp ${BBGEDIR}/LightCone.cpp
${BBGEDIR}/Model.cpp ${BBGEDIR}/Model.cpp