This commit is contained in:
parent
826713a65c
commit
8bd4b0ce54
4 changed files with 136 additions and 24 deletions
|
@ -264,10 +264,10 @@ void CGameScene::initLevel()
|
||||||
pos.vx+=32; createPickup(PICKUP__HELMET,&pos);
|
pos.vx+=32; createPickup(PICKUP__HELMET,&pos);
|
||||||
pos.vx+=32; createPickup(PICKUP__QUEST_ITEM__TEST,&pos);
|
pos.vx+=32; createPickup(PICKUP__QUEST_ITEM__TEST,&pos);
|
||||||
|
|
||||||
// CNpcPlatform *platform;
|
CNpcPlatform *platform;
|
||||||
// platform=new ("test platform") CNpcPlatform;
|
platform=new ("test platform") CNpcPlatform;
|
||||||
// platform->init();
|
platform->init();
|
||||||
// platform->setLayerCollision( Level.getCollisionLayer() );
|
platform->setLayerCollision( Level.getCollisionLayer() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s_levelFinished=false;
|
s_levelFinished=false;
|
||||||
|
|
|
@ -421,7 +421,7 @@ void CPlayer::render()
|
||||||
CPlayerThing::render();
|
CPlayerThing::render();
|
||||||
|
|
||||||
#ifdef _STATE_DEBUG_
|
#ifdef _STATE_DEBUG_
|
||||||
sprintf(posBuf,"%03d (%02d) ,%03d (%02d) = dfg:%+02d",Pos.vx,Pos.vx&0x0f,Pos.vy,Pos.vy&0x0f,m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy));
|
sprintf(posBuf,"%03d (%02d) ,%03d (%02d) = dfg:%+02d",Pos.vx,Pos.vx&0x0f,Pos.vy,Pos.vy&0x0f,getHeightFromGround(Pos.vx,Pos.vy));
|
||||||
s_debugFont.print(40,40,posBuf);
|
s_debugFont.print(40,40,posBuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -516,6 +516,33 @@ void CPlayer::setMapSize(DVECTOR _mapSize)
|
||||||
m_mapEdge.vy=_mapSize.vy*MAP2D_BLOCKSTEPSIZE;
|
m_mapEdge.vy=_mapSize.vy*MAP2D_BLOCKSTEPSIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------
|
||||||
|
Function:
|
||||||
|
Purpose:
|
||||||
|
Params:
|
||||||
|
Returns:
|
||||||
|
---------------------------------------------------------------------- */
|
||||||
|
int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight)
|
||||||
|
{
|
||||||
|
int height;
|
||||||
|
if(isOnPlatform())
|
||||||
|
{
|
||||||
|
DVECTOR platformPos;
|
||||||
|
platformPos=m_platform->getPos();
|
||||||
|
height=platformPos.vy-Pos.vy;
|
||||||
|
// if(height<-_maxHeight)
|
||||||
|
// {
|
||||||
|
// height=-_maxHeight;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight);
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
Function:
|
Function:
|
||||||
Purpose:
|
Purpose:
|
||||||
|
@ -663,6 +690,8 @@ void CPlayer::respawn()
|
||||||
s_health=MAX_HEALTH;
|
s_health=MAX_HEALTH;
|
||||||
m_invincibleFrameCount=INVINCIBLE_FRAMES__START;
|
m_invincibleFrameCount=INVINCIBLE_FRAMES__START;
|
||||||
Pos=m_respawnPos;
|
Pos=m_respawnPos;
|
||||||
|
|
||||||
|
clearPlatform();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
@ -722,7 +751,6 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage)
|
||||||
{
|
{
|
||||||
CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_DEFEATED_JINGLE);
|
CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_DEFEATED_JINGLE);
|
||||||
setMode(PLAYER_MODE_DEAD);
|
setMode(PLAYER_MODE_DEAD);
|
||||||
// setState(STATE_DEAD);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -966,7 +994,6 @@ void CPlayer::setPlatform( CThing *newPlatform )
|
||||||
Params:
|
Params:
|
||||||
Returns:
|
Returns:
|
||||||
---------------------------------------------------------------------- */
|
---------------------------------------------------------------------- */
|
||||||
/*
|
|
||||||
void CPlayer::shove( DVECTOR move )
|
void CPlayer::shove( DVECTOR move )
|
||||||
{
|
{
|
||||||
DVECTOR newPos;
|
DVECTOR newPos;
|
||||||
|
@ -987,8 +1014,87 @@ void CPlayer::shove( DVECTOR move )
|
||||||
Pos.vx = newPos.vx;
|
Pos.vx = newPos.vx;
|
||||||
Pos.vy = newPos.vy;
|
Pos.vy = newPos.vy;
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
|
int colHeight;
|
||||||
|
|
||||||
|
// X movement
|
||||||
|
colHeight=m_layerCollision->getHeightFromGround(Pos.vx+move.vx,Pos.vy,5);
|
||||||
|
if(colHeight<0)
|
||||||
|
{
|
||||||
|
// Stop at the edge of the obstruction
|
||||||
|
int dir,vx,cx,i;
|
||||||
|
if(move.vx<0)
|
||||||
|
{
|
||||||
|
dir=-1;
|
||||||
|
vx=move.vx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir=+1;
|
||||||
|
vx=move.vx;
|
||||||
|
}
|
||||||
|
cx=Pos.vx;
|
||||||
|
for(i=0;i<vx;i++)
|
||||||
|
{
|
||||||
|
if(m_layerCollision->getHeightFromGround(cx,Pos.vy)<0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cx+=dir;
|
||||||
|
}
|
||||||
|
Pos.vx=cx-dir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No obstruction
|
||||||
|
Pos.vx+=move.vx;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Y movement
|
||||||
|
colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy+move.vy,5);
|
||||||
|
if(colHeight<0)
|
||||||
|
{
|
||||||
|
// Stop at the edge of the obstruction
|
||||||
|
int dir,vy,cy,i;
|
||||||
|
if(move.vy<0)
|
||||||
|
{
|
||||||
|
dir=-1;
|
||||||
|
vy=move.vy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dir=+1;
|
||||||
|
vy=move.vy;
|
||||||
|
}
|
||||||
|
cy=Pos.vy;
|
||||||
|
for(i=0;i<vy;i++)
|
||||||
|
{
|
||||||
|
if(m_layerCollision->getHeightFromGround(Pos.vx,cy)<0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cy+=dir;
|
||||||
|
}
|
||||||
|
Pos.vy=cy-dir;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No obstruction
|
||||||
|
Pos.vy+=move.vy;
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
void CPlayer::setPlatform(CThing *_newPlatform)
|
||||||
|
{
|
||||||
|
m_platform=_newPlatform;
|
||||||
|
}
|
||||||
|
void CPlayer::clearPlatform()
|
||||||
|
{
|
||||||
|
m_platform=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================
|
/*===========================================================================
|
||||||
end */
|
end */
|
||||||
|
|
|
@ -139,7 +139,7 @@ public:
|
||||||
virtual void shutdown();
|
virtual void shutdown();
|
||||||
virtual void think(int _frames);
|
virtual void think(int _frames);
|
||||||
virtual void render();
|
virtual void render();
|
||||||
// virtual void shove(DVECTOR move);
|
virtual void shove(DVECTOR move);
|
||||||
|
|
||||||
DVECTOR getCameraPos() {return m_cameraPos;}
|
DVECTOR getCameraPos() {return m_cameraPos;}
|
||||||
|
|
||||||
|
@ -147,6 +147,8 @@ public:
|
||||||
void setMapSize(DVECTOR _mapSize);
|
void setMapSize(DVECTOR _mapSize);
|
||||||
void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;}
|
void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;}
|
||||||
|
|
||||||
|
int getHeightFromGround(int _x,int _y,int _maxHeight=32);
|
||||||
|
|
||||||
void addHealth(int _health);
|
void addHealth(int _health);
|
||||||
void addLife();
|
void addLife();
|
||||||
|
|
||||||
|
@ -249,8 +251,12 @@ private:
|
||||||
|
|
||||||
// Platforms
|
// Platforms
|
||||||
public:
|
public:
|
||||||
void setPlatform( CThing *newPlatform ) {;}
|
void setPlatform(CThing *_newPlatform);
|
||||||
void clearPlatform() {;}
|
void clearPlatform();
|
||||||
|
CThing *isOnPlatform() {return m_platform;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CThing *m_platform;
|
||||||
/*
|
/*
|
||||||
private:
|
private:
|
||||||
CThing *m_platform;
|
CThing *m_platform;
|
||||||
|
|
|
@ -242,7 +242,7 @@ void CPlayerModeBase::thinkVerticalMovement()
|
||||||
collision=m_player->getLayerCollision();
|
collision=m_player->getLayerCollision();
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
|
|
||||||
colHeight=collision->getHeightFromGround(pos.vx,pos.vy,1);
|
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy,1);
|
||||||
|
|
||||||
//New collision stuff (pkg)
|
//New collision stuff (pkg)
|
||||||
//if(m_layerCollision->getCollisionType(Pos.vx,Pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT))&COLLISION_TYPE_MASK)
|
//if(m_layerCollision->getCollisionType(Pos.vx,Pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT))&COLLISION_TYPE_MASK)
|
||||||
|
@ -257,7 +257,7 @@ void CPlayerModeBase::thinkVerticalMovement()
|
||||||
if(m_moveVelocity.vy>0)
|
if(m_moveVelocity.vy>0)
|
||||||
{
|
{
|
||||||
// Yes.. Check to see if we're about to hit/go through the ground
|
// Yes.. Check to see if we're about to hit/go through the ground
|
||||||
colHeight=collision->getHeightFromGround(pos.vx,pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT),getPlayerMetrics()->m_metric[PM__TERMINAL_VELOCITY]+1);
|
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy+(m_moveVelocity.vy>>VELOCITY_SHIFT),getPlayerMetrics()->m_metric[PM__TERMINAL_VELOCITY]+1);
|
||||||
|
|
||||||
if(colHeight<=0)
|
if(colHeight<=0)
|
||||||
{
|
{
|
||||||
|
@ -347,11 +347,11 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
// return;
|
// return;
|
||||||
//}
|
//}
|
||||||
int colHeight;
|
int colHeight;
|
||||||
colHeight=collision->getHeightFromGround(pos.vx,pos.vy,5);
|
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy,5);
|
||||||
if(colHeight==0)
|
if(colHeight==0)
|
||||||
{
|
{
|
||||||
// Ok.. we're on the ground. What happens if we move left/right
|
// Ok.. we're on the ground. What happens if we move left/right
|
||||||
colHeight=collision->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy);
|
colHeight=m_player->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy);
|
||||||
if(colHeight<-8)
|
if(colHeight<-8)
|
||||||
{
|
{
|
||||||
// Big step up. Stop at the edge of the obstruction
|
// Big step up. Stop at the edge of the obstruction
|
||||||
|
@ -369,7 +369,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
cx=pos.vx;
|
cx=pos.vx;
|
||||||
for(i=0;i<vx;i++)
|
for(i=0;i<vx;i++)
|
||||||
{
|
{
|
||||||
if(collision->getHeightFromGround(cx,pos.vy)<-8)
|
if(m_player->getHeightFromGround(cx,pos.vy)<-8)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
|
|
||||||
// Get the height at this new position and then try the step-up code below.
|
// 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
|
// Without this, there are problems when you run up a slope and hit a wall at the same time
|
||||||
colHeight=collision->getHeightFromGround(pos.vx,pos.vy);
|
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy);
|
||||||
}
|
}
|
||||||
if(colHeight&&colHeight>=-8&&colHeight<=8)
|
if(colHeight&&colHeight>=-8&&colHeight<=8)
|
||||||
{
|
{
|
||||||
|
@ -400,7 +400,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
// if(!(colHeight<0&&m_currentState==STATE_JUMP)) // Lets you jump through platforms from below
|
// if(!(colHeight<0&&m_currentState==STATE_JUMP)) // Lets you jump through platforms from below
|
||||||
if(colHeight>=0) // Lets you jump through platforms from below
|
if(colHeight>=0) // Lets you jump through platforms from below
|
||||||
{
|
{
|
||||||
colHeight=collision->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy,5);
|
colHeight=m_player->getHeightFromGround(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy,5);
|
||||||
if(colHeight<0)
|
if(colHeight<0)
|
||||||
{
|
{
|
||||||
// Stop at the edge of the obstruction
|
// Stop at the edge of the obstruction
|
||||||
|
@ -408,7 +408,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
if(m_moveVelocity.vx<0)
|
if(m_moveVelocity.vx<0)
|
||||||
{
|
{
|
||||||
dir=-1;
|
dir=-1;
|
||||||
vx=-m_moveVelocity.vx>>VELOCITY_SHIFT;
|
vx=m_moveVelocity.vx>>VELOCITY_SHIFT;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -418,7 +418,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
|
||||||
cx=pos.vx;
|
cx=pos.vx;
|
||||||
for(i=0;i<vx;i++)
|
for(i=0;i<vx;i++)
|
||||||
{
|
{
|
||||||
if(collision->getHeightFromGround(cx,pos.vy)<0)
|
if(m_player->getHeightFromGround(cx,pos.vy)<0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -533,11 +533,11 @@ int CPlayerModeBase::isOnEdge()
|
||||||
collision=m_player->getLayerCollision();
|
collision=m_player->getLayerCollision();
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
ret=0;
|
ret=0;
|
||||||
if(collision->getHeightFromGround(pos.vx-csize,pos.vy,cheight+1)>cheight)
|
if(m_player->getHeightFromGround(pos.vx-csize,pos.vy,cheight+1)>cheight)
|
||||||
{
|
{
|
||||||
ret=FACING_LEFT;
|
ret=FACING_LEFT;
|
||||||
}
|
}
|
||||||
else if(collision->getHeightFromGround(pos.vx+csize,pos.vy,cheight+1)>cheight)
|
else if(m_player->getHeightFromGround(pos.vx+csize,pos.vy,cheight+1)>cheight)
|
||||||
{
|
{
|
||||||
ret=FACING_RIGHT;
|
ret=FACING_RIGHT;
|
||||||
}
|
}
|
||||||
|
@ -554,14 +554,14 @@ int CPlayerModeBase::canMoveLeft()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
return m_player->getLayerCollision()->getHeightFromGround(pos.vx-1,pos.vy,16)>-8?true:false;
|
return m_player->getHeightFromGround(pos.vx-1,pos.vy,16)>-8?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPlayerModeBase::canMoveRight()
|
int CPlayerModeBase::canMoveRight()
|
||||||
{
|
{
|
||||||
DVECTOR pos;
|
DVECTOR pos;
|
||||||
pos=m_player->getPlayerPos();
|
pos=m_player->getPlayerPos();
|
||||||
return m_player->getLayerCollision()->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false;
|
return m_player->getHeightFromGround(pos.vx+1,pos.vy,16)>-8?true:false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue