//--------------------------HANDLE DIRECTION CHANGE-------------------------- private void checkForDirectionChange(Entity e) { SmushComponent smushComp = ( SmushComponent )e.getComponent(GlobalVars.SMUSH_COMPONENT_NAME); VelocityComponent velComp = ( VelocityComponent )e.getComponent(GlobalVars.VELOCITY_COMPONENT_NAME); float stopBuffer = 0.01f; if (smushComp.getFallSpeed().X != 0 && Math.Abs(velComp.x) < stopBuffer) { if (smushComp.isFalling()) { startLowerWait(e); } else if (smushComp.isRising()) { startUpperWait(e); } } if (smushComp.getFallSpeed().Y != 0 && Math.Abs(velComp.y) < stopBuffer) { if (smushComp.isFalling()) { startLowerWait(e); } else if (smushComp.isRising()) { startUpperWait(e); } } }
private void startFall(VelocityComponent velComp, SmushComponent smushComp) { velComp.setVelocity(smushComp.getFallSpeed()); smushComp.setStateFall(); }