This commit is contained in:
parent
a0467f42f5
commit
7bbfd89bba
@ -342,9 +342,9 @@ if(newmode!=-1)
|
||||
{
|
||||
m_squeakyBootsTimer--;
|
||||
}
|
||||
if(m_invinvibilityRingTimer)
|
||||
if(m_invincibilityRingTimer)
|
||||
{
|
||||
m_invinvibilityRingTimer--;
|
||||
m_invincibilityRingTimer--;
|
||||
}
|
||||
|
||||
// Flashing..
|
||||
@ -542,6 +542,12 @@ int healthr=200;
|
||||
int healthg=75;
|
||||
int healthb=75;
|
||||
|
||||
#ifdef __USER_paul__
|
||||
#define NUM_LASTPOS 50
|
||||
static DVECTOR lastpos[NUM_LASTPOS];
|
||||
static int lastposnum=0;
|
||||
#endif
|
||||
|
||||
#ifdef __USER_paul__
|
||||
int mouth=-1,eyes=-1;
|
||||
#endif
|
||||
@ -554,6 +560,23 @@ sprintf(posBuf,"%03d (%02d) ,%03d (%02d) = dfg:%+02d",Pos.vx,Pos.vx&0x0f,Pos.vy,
|
||||
m_fontBank->print(40,40,posBuf);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __USER_paul__
|
||||
if(Pos.vx!=lastpos[lastposnum].vx||Pos.vy!=lastpos[lastposnum].vy)
|
||||
{
|
||||
lastposnum=(lastposnum+1)%NUM_LASTPOS;
|
||||
lastpos[lastposnum]=Pos;
|
||||
}
|
||||
for(int i=0;i<NUM_LASTPOS;i++)
|
||||
{
|
||||
int x,y;
|
||||
x=lastpos[i].vx-m_cameraPos.vx;
|
||||
y=lastpos[i].vy-m_cameraPos.vy;
|
||||
DrawLine(x-4,y-4,x+4,y+4,0,0,255,0);
|
||||
DrawLine(x-4,y+4,x+4,y-4,0,0,255,0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Render
|
||||
if(m_invincibleFrameCount==0||m_invincibleFrameCount&2)
|
||||
{
|
||||
@ -882,7 +905,7 @@ void CPlayer::respawn()
|
||||
|
||||
m_glassesFlag=0;
|
||||
m_squeakyBootsTimer=0;
|
||||
m_invinvibilityRingTimer=0;
|
||||
m_invincibilityRingTimer=0;
|
||||
m_bubbleAmmo=0;
|
||||
m_jellyAmmo=0;
|
||||
|
||||
@ -920,13 +943,11 @@ int CPlayer::canDoLookAround()
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
#ifdef __VERSION_DEBUG__
|
||||
int invincibleSponge=false; // NB: This is for debugging purposes only so don't try and use it for a permenant cheat mode..
|
||||
#endif
|
||||
void CPlayer::takeDamage(DAMAGE_TYPE _damage)
|
||||
{
|
||||
if(m_invincibleFrameCount==0&& // Don't take damage if still recovering from the last hit
|
||||
m_invinvibilityRingTimer==0&& // Or if we have the invincibility ring on
|
||||
m_invincibilityRingTimer==0&& // Or if we have the invincibility ring on
|
||||
m_currentMode!=PLAYER_MODE_DEAD) // Or already dead! :)
|
||||
{
|
||||
int ouchThatHurt=true;
|
||||
@ -960,9 +981,7 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage)
|
||||
|
||||
if(ouchThatHurt)
|
||||
{
|
||||
#ifdef __VERSION_DEBUG__
|
||||
if(invincibleSponge){m_invincibleFrameCount=INVINCIBLE_FRAMES__HIT;return;}
|
||||
#endif
|
||||
if(m_health)
|
||||
{
|
||||
m_invincibleFrameCount=INVINCIBLE_FRAMES__HIT;
|
||||
@ -1168,6 +1187,232 @@ bool CPlayer::getHasPlatformCollided()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CPlayer::moveVertical(int _moveDistance)
|
||||
{
|
||||
DVECTOR pos;
|
||||
int hitGround;
|
||||
// int colHeight;
|
||||
|
||||
pos=Pos;
|
||||
hitGround=false;
|
||||
|
||||
// Are we falling?
|
||||
if(_moveDistance>0)
|
||||
{
|
||||
int colHeightBefore,colHeightAfter;
|
||||
|
||||
// Yes.. Check to see if we're about to hit/go through the ground
|
||||
colHeightBefore=getHeightFromGround(pos.vx,pos.vy,16);
|
||||
colHeightAfter=getHeightFromGround(pos.vx,pos.vy+_moveDistance,16);
|
||||
if(colHeightBefore>=0&&colHeightAfter<=0)
|
||||
{
|
||||
// Stick at ground level
|
||||
pos.vy+=colHeightAfter+_moveDistance;
|
||||
_moveDistance=0;
|
||||
hitGround=true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
}
|
||||
else// if(getHeightFromGround(pos.vx,pos.vy+_moveDistance,1))
|
||||
{
|
||||
// Must be below ground
|
||||
// Are we jumping into an impassable block?
|
||||
if(_moveDistance>0&&
|
||||
(m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL)
|
||||
{
|
||||
pos.vy=(pos.vy&0xfff0);
|
||||
_moveDistance=0;
|
||||
hitGround=true;
|
||||
}
|
||||
else if(isOnPlatform()&&_moveDistance>=0)
|
||||
{
|
||||
pos.vy+=colHeight;
|
||||
hitGround=true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
pos.vy+=_moveDistance;
|
||||
setPlayerPos(&pos);
|
||||
|
||||
return hitGround;
|
||||
|
||||
|
||||
/*
|
||||
DVECTOR pos;
|
||||
int hitGround;
|
||||
int colHeight;
|
||||
|
||||
pos=Pos;
|
||||
hitGround=false;
|
||||
colHeight=getHeightFromGround(pos.vx,pos.vy,1);
|
||||
if(colHeight>=0)
|
||||
{
|
||||
// Above or on the ground
|
||||
// Are we falling?
|
||||
if(_moveDistance>0)
|
||||
{
|
||||
// Yes.. Check to see if we're about to hit/go through the ground
|
||||
colHeight=getHeightFromGround(pos.vx,pos.vy+_moveDistance,16);
|
||||
|
||||
if(colHeight<=0)
|
||||
{
|
||||
// Stick at ground level
|
||||
pos.vy+=colHeight+_moveDistance;
|
||||
_moveDistance=0;
|
||||
hitGround=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else// if(getHeightFromGround(pos.vx,pos.vy+_moveDistance,1))
|
||||
{
|
||||
// Must be below ground
|
||||
// Are we jumping into an impassable block?
|
||||
if(_moveDistance>0&&
|
||||
(m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL)
|
||||
{
|
||||
pos.vy=(pos.vy&0xfff0);
|
||||
_moveDistance=0;
|
||||
hitGround=true;
|
||||
}
|
||||
else if(isOnPlatform()&&_moveDistance>=0)
|
||||
{
|
||||
pos.vy+=colHeight;
|
||||
hitGround=true;
|
||||
}
|
||||
}
|
||||
|
||||
pos.vy+=_moveDistance;
|
||||
setPlayerPos(&pos);
|
||||
|
||||
return hitGround;
|
||||
*/
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CPlayer::moveHorizontal(int _moveDistance)
|
||||
{
|
||||
int hitWall;
|
||||
|
||||
hitWall=false;
|
||||
if(_moveDistance)
|
||||
{
|
||||
CLayerCollision *collision;
|
||||
DVECTOR pos;
|
||||
int colHeight;
|
||||
|
||||
collision=getLayerCollision();
|
||||
pos=getPlayerPos();
|
||||
colHeight=getHeightFromGround(pos.vx,pos.vy,5);
|
||||
if(colHeight==0)
|
||||
{
|
||||
// Ok.. we're on the ground. What happens if we move left/right
|
||||
colHeight=getHeightFromGround(pos.vx+_moveDistance,pos.vy);
|
||||
if(colHeight<-8)
|
||||
{
|
||||
// Big step up. Stop at the edge of the obstruction
|
||||
int dir,vx,cx,i;
|
||||
if(_moveDistance<0)
|
||||
{
|
||||
dir=-1;
|
||||
vx=-_moveDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir=+1;
|
||||
vx=_moveDistance;
|
||||
}
|
||||
cx=pos.vx;
|
||||
for(i=0;i<vx;i++)
|
||||
{
|
||||
if(getHeightFromGround(cx,pos.vy)<-8)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cx+=dir;
|
||||
}
|
||||
if(i)
|
||||
pos.vx=cx-dir;
|
||||
|
||||
hitWall=true;
|
||||
_moveDistance=0;
|
||||
|
||||
// Get the height at this new position and then try the step-up code below.
|
||||
// Without this, there are problems when you run up a slope and hit a wall at the same time
|
||||
colHeight=getHeightFromGround(pos.vx,pos.vy);
|
||||
}
|
||||
if(colHeight&&colHeight>=-8&&colHeight<=8)
|
||||
{
|
||||
// Small step up/down. Follow the contour of the level
|
||||
pos.vy+=colHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// In the air
|
||||
/*
|
||||
if((getLayerCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)==(6<<COLLISION_TYPE_FLAG_SHIFT))
|
||||
{
|
||||
// Hit an impassable block
|
||||
pos.vx&=0xfff0;
|
||||
if(_moveDistance>0)
|
||||
{
|
||||
pos.vx+=15;
|
||||
}
|
||||
_moveDistance=0;
|
||||
}
|
||||
else */if(colHeight>=0) // Lets you jump through platforms from below
|
||||
{
|
||||
colHeight=getHeightFromGround(pos.vx+_moveDistance,pos.vy,5);
|
||||
if(colHeight<0)
|
||||
{
|
||||
// Stop at the edge of the obstruction
|
||||
int dir,vx,cx,i;
|
||||
if(_moveDistance<0)
|
||||
{
|
||||
dir=-1;
|
||||
vx=_moveDistance;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir=+1;
|
||||
vx=_moveDistance;
|
||||
}
|
||||
cx=pos.vx;
|
||||
for(i=0;i<vx;i++)
|
||||
{
|
||||
if(getHeightFromGround(cx,pos.vy)<0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cx+=dir;
|
||||
}
|
||||
if(i)
|
||||
pos.vx=cx-dir;
|
||||
_moveDistance=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos.vx+=_moveDistance;
|
||||
setPlayerPos(&pos);
|
||||
}
|
||||
|
||||
return hitWall;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -149,7 +149,8 @@ public:
|
||||
virtual void think(int _frames);
|
||||
virtual void render();
|
||||
virtual void shove(DVECTOR move);
|
||||
// virtual int moveVertical(int _moveDistance);
|
||||
virtual int moveVertical(int _moveDistance);
|
||||
virtual int moveHorizontal(int _moveDistance);
|
||||
virtual void setHasPlatformCollided( bool newVal );
|
||||
virtual bool getHasPlatformCollided();
|
||||
|
||||
@ -271,7 +272,7 @@ public:
|
||||
int isWearingGlasses() {return m_glassesFlag;}
|
||||
void giveSqueakyBoots() {m_squeakyBootsTimer=SQUEAKY_BOOTS_TIME;}
|
||||
int isWearingBoots() {return m_squeakyBootsTimer;}
|
||||
void giveInvinvibilityRing() {m_invinvibilityRingTimer=INVINCIBILITY_RING_TIME;}
|
||||
void giveInvincibilityRing() {m_invincibilityRingTimer=INVINCIBILITY_RING_TIME;}
|
||||
void giveDivingHelmet() {m_divingHelmet=true;}
|
||||
|
||||
void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;}
|
||||
@ -285,7 +286,7 @@ public:
|
||||
private:
|
||||
int m_glassesFlag;
|
||||
int m_squeakyBootsTimer;
|
||||
int m_invinvibilityRingTimer;
|
||||
int m_invincibilityRingTimer;
|
||||
int m_divingHelmet;
|
||||
int m_bubbleAmmo;
|
||||
int m_jellyAmmo;
|
||||
|
@ -71,6 +71,8 @@ void CPlayerModeDead::think()
|
||||
m_player->setAnimFrame(m_deadTime);
|
||||
}
|
||||
|
||||
m_player->moveVertical(5);
|
||||
|
||||
if((m_deadTime>DEATH_DELAY&&m_player->getPadInputDown()&PI_ACTION)||
|
||||
m_deadTime>DEATH_TIMEOUT)
|
||||
{
|
||||
@ -104,16 +106,16 @@ void CPlayerModeDead::render(DVECTOR *_pos)
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
/*
|
||||
void CPlayerModeDead::fall()
|
||||
{
|
||||
m_moveVelocity.vy+=getPlayerMetrics()->m_metric[DEFAULT_PLAYER_PLAYER_GRAVITY];
|
||||
if(m_moveVelocity.vy>=metrics->m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<<VELOCITY_SHIFT)
|
||||
/*
|
||||
m_yVelocity+=getPlayerMetrics()->m_metric[DEFAULT_PLAYER_PLAYER_GRAVITY];
|
||||
if(m_yVelocity>=metrics->m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<<VELOCITY_SHIFT)
|
||||
{
|
||||
m_moveVelocity.vy=metrics->m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<<VELOCITY_SHIFT;
|
||||
}
|
||||
m_yVelocity=metrics->m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<<VELOCITY_SHIFT;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*===========================================================================
|
||||
end */
|
||||
|
@ -50,8 +50,8 @@ private:
|
||||
};
|
||||
int m_deadTime;
|
||||
|
||||
|
||||
// void fall();
|
||||
void fall();
|
||||
int m_yVelocity;
|
||||
|
||||
};
|
||||
|
||||
|
@ -252,59 +252,23 @@ ATTACK_STATE CPlayerModeBase::getAttackState()
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerModeBase::thinkVerticalMovement()
|
||||
{
|
||||
CLayerCollision *collision;
|
||||
DVECTOR pos;
|
||||
int colHeight;
|
||||
|
||||
collision=m_player->getLayerCollision();
|
||||
pos=m_player->getPlayerPos();
|
||||
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy,1);
|
||||
if(colHeight>=0)
|
||||
if(m_player->moveVertical(m_moveVelocity.vy>>VELOCITY_SHIFT))
|
||||
{
|
||||
// Above or on the ground
|
||||
// Are we falling?
|
||||
if(m_moveVelocity.vy>0)
|
||||
{
|
||||
// Yes.. Check to see if we're about to hit/go through the ground
|
||||
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT),getPlayerMetrics()->m_metric[PM__TERMINAL_VELOCITY]+1);
|
||||
|
||||
if(colHeight<=0)
|
||||
{
|
||||
// Just hit the ground
|
||||
// Stick at ground level
|
||||
pos.vy+=(m_moveVelocity.vy>>VELOCITY_SHIFT)+colHeight;
|
||||
playerHasHitGround();
|
||||
}
|
||||
}
|
||||
else if(colHeight)
|
||||
{
|
||||
if(m_currentState!=STATE_FALL&&m_currentState!=STATE_FALLFAR&&
|
||||
else if(m_currentState!=STATE_FALL&&m_currentState!=STATE_FALLFAR&&
|
||||
m_currentState!=STATE_BUTTFALL&&m_currentState!=STATE_BUTTBOUNCE&&
|
||||
m_currentState!=STATE_JUMP)
|
||||
{
|
||||
DVECTOR pos;
|
||||
pos=m_player->getPlayerPos();
|
||||
if(m_player->getHeightFromGround(pos.vx,pos.vy,1)!=0)
|
||||
{
|
||||
// Was floating in the air.. fall!
|
||||
setState(STATE_FALL);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((m_player->getLayerCollision()->getCollisionBlock(pos.vx,pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT))&COLLISION_TYPE_MASK)==(6<<COLLISION_TYPE_FLAG_SHIFT))
|
||||
{
|
||||
// Hit an impassable block
|
||||
pos.vy=(pos.vy&0xfff0)+16;
|
||||
m_moveVelocity.vy=0;
|
||||
}
|
||||
else if ( m_player->isOnPlatform() && m_moveVelocity.vy >= 0 )
|
||||
{
|
||||
pos.vy += colHeight;
|
||||
playerHasHitGround();
|
||||
}
|
||||
}
|
||||
|
||||
pos.vy+=m_moveVelocity.vy>>VELOCITY_SHIFT;
|
||||
m_player->setPlayerPos(&pos);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
@ -314,109 +278,14 @@ void CPlayerModeBase::thinkVerticalMovement()
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayerModeBase::thinkHorizontalMovement()
|
||||
{
|
||||
if(m_moveVelocity.vx)
|
||||
if(m_player->moveHorizontal(m_moveVelocity.vx>>VELOCITY_SHIFT))
|
||||
{
|
||||
CLayerCollision *collision;
|
||||
DVECTOR pos;
|
||||
int colHeight;
|
||||
|
||||
collision=m_player->getLayerCollision();
|
||||
pos=m_player->getPlayerPos();
|
||||
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy,5);
|
||||
if(colHeight==0)
|
||||
{
|
||||
// Ok.. we're on the ground. What happens if we move left/right
|
||||
colHeight=m_player->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy);
|
||||
if(colHeight<-8)
|
||||
{
|
||||
// Big step up. Stop at the edge of the obstruction
|
||||
int dir,vx,cx,i;
|
||||
if(m_moveVelocity.vx<0)
|
||||
{
|
||||
dir=-1;
|
||||
vx=-m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir=+1;
|
||||
vx=m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||
}
|
||||
cx=pos.vx;
|
||||
for(i=0;i<vx;i++)
|
||||
{
|
||||
if(m_player->getHeightFromGround(cx,pos.vy)<-8)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cx+=dir;
|
||||
}
|
||||
if(i)
|
||||
pos.vx=cx-dir;
|
||||
|
||||
// If running then go to idle, otherwise leave in same state
|
||||
if(m_currentState==STATE_RUN)
|
||||
{
|
||||
setState(STATE_IDLE);
|
||||
}
|
||||
m_moveVelocity.vx=0;
|
||||
|
||||
// Get the height at this new position and then try the step-up code below.
|
||||
// Without this, there are problems when you run up a slope and hit a wall at the same time
|
||||
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy);
|
||||
}
|
||||
if(colHeight&&colHeight>=-8&&colHeight<=8)
|
||||
{
|
||||
// Small step up/down. Follow the contour of the level
|
||||
pos.vy+=colHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// In the air
|
||||
if((m_player->getLayerCollision()->getCollisionBlock(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy)&COLLISION_TYPE_MASK)==(6<<COLLISION_TYPE_FLAG_SHIFT))
|
||||
{
|
||||
// Hit an impassable block
|
||||
pos.vx&=0xfff0;
|
||||
if(m_moveVelocity.vx>0)
|
||||
{
|
||||
pos.vx+=15;
|
||||
}
|
||||
m_moveVelocity.vx=0;
|
||||
}
|
||||
else if(colHeight>=0) // Lets you jump through platforms from below
|
||||
{
|
||||
colHeight=m_player->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy,5);
|
||||
if(colHeight<0)
|
||||
{
|
||||
// Stop at the edge of the obstruction
|
||||
int dir,vx,cx,i;
|
||||
if(m_moveVelocity.vx<0)
|
||||
{
|
||||
dir=-1;
|
||||
vx=m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
dir=+1;
|
||||
vx=m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||
}
|
||||
cx=pos.vx;
|
||||
for(i=0;i<vx;i++)
|
||||
{
|
||||
if(m_player->getHeightFromGround(cx,pos.vy)<0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
cx+=dir;
|
||||
}
|
||||
if(i)
|
||||
pos.vx=cx-dir;
|
||||
m_moveVelocity.vx=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
pos.vx+=m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||
m_player->setPlayerPos(&pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user