This commit is contained in:
Paul 2001-03-29 19:19:33 +00:00
parent 826713a65c
commit 8bd4b0ce54
4 changed files with 136 additions and 24 deletions

View File

@ -264,10 +264,10 @@ void CGameScene::initLevel()
pos.vx+=32; createPickup(PICKUP__HELMET,&pos);
pos.vx+=32; createPickup(PICKUP__QUEST_ITEM__TEST,&pos);
// CNpcPlatform *platform;
// platform=new ("test platform") CNpcPlatform;
// platform->init();
// platform->setLayerCollision( Level.getCollisionLayer() );
CNpcPlatform *platform;
platform=new ("test platform") CNpcPlatform;
platform->init();
platform->setLayerCollision( Level.getCollisionLayer() );
#endif
s_levelFinished=false;

View File

@ -421,7 +421,7 @@ void CPlayer::render()
CPlayerThing::render();
#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);
#endif
@ -516,6 +516,33 @@ void CPlayer::setMapSize(DVECTOR _mapSize)
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:
Purpose:
@ -663,6 +690,8 @@ void CPlayer::respawn()
s_health=MAX_HEALTH;
m_invincibleFrameCount=INVINCIBLE_FRAMES__START;
Pos=m_respawnPos;
clearPlatform();
}
/*----------------------------------------------------------------------
@ -722,7 +751,6 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage)
{
CSoundMediator::playSfx(CSoundMediator::SFX_SPONGEBOB_DEFEATED_JINGLE);
setMode(PLAYER_MODE_DEAD);
// setState(STATE_DEAD);
}
}
}
@ -966,7 +994,6 @@ void CPlayer::setPlatform( CThing *newPlatform )
Params:
Returns:
---------------------------------------------------------------------- */
/*
void CPlayer::shove( DVECTOR move )
{
DVECTOR newPos;
@ -987,8 +1014,87 @@ void CPlayer::shove( DVECTOR move )
Pos.vx = newPos.vx;
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 */

View File

@ -139,7 +139,7 @@ public:
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
// virtual void shove(DVECTOR move);
virtual void shove(DVECTOR move);
DVECTOR getCameraPos() {return m_cameraPos;}
@ -147,6 +147,8 @@ public:
void setMapSize(DVECTOR _mapSize);
void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;}
int getHeightFromGround(int _x,int _y,int _maxHeight=32);
void addHealth(int _health);
void addLife();
@ -249,8 +251,12 @@ private:
// Platforms
public:
void setPlatform( CThing *newPlatform ) {;}
void clearPlatform() {;}
void setPlatform(CThing *_newPlatform);
void clearPlatform();
CThing *isOnPlatform() {return m_platform;}
private:
CThing *m_platform;
/*
private:
CThing *m_platform;

View File

@ -242,7 +242,7 @@ void CPlayerModeBase::thinkVerticalMovement()
collision=m_player->getLayerCollision();
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)
//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)
{
// 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)
{
@ -347,11 +347,11 @@ void CPlayerModeBase::thinkHorizontalMovement()
// return;
//}
int colHeight;
colHeight=collision->getHeightFromGround(pos.vx,pos.vy,5);
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=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)
{
// Big step up. Stop at the edge of the obstruction
@ -369,7 +369,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
cx=pos.vx;
for(i=0;i<vx;i++)
{
if(collision->getHeightFromGround(cx,pos.vy)<-8)
if(m_player->getHeightFromGround(cx,pos.vy)<-8)
{
break;
}
@ -386,7 +386,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
// 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=collision->getHeightFromGround(pos.vx,pos.vy);
colHeight=m_player->getHeightFromGround(pos.vx,pos.vy);
}
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) // 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)
{
// Stop at the edge of the obstruction
@ -408,7 +408,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
if(m_moveVelocity.vx<0)
{
dir=-1;
vx=-m_moveVelocity.vx>>VELOCITY_SHIFT;
vx=m_moveVelocity.vx>>VELOCITY_SHIFT;
}
else
{
@ -418,7 +418,7 @@ void CPlayerModeBase::thinkHorizontalMovement()
cx=pos.vx;
for(i=0;i<vx;i++)
{
if(collision->getHeightFromGround(cx,pos.vy)<0)
if(m_player->getHeightFromGround(cx,pos.vy)<0)
{
break;
}
@ -533,11 +533,11 @@ int CPlayerModeBase::isOnEdge()
collision=m_player->getLayerCollision();
pos=m_player->getPlayerPos();
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;
}
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;
}
@ -554,14 +554,14 @@ int CPlayerModeBase::canMoveLeft()
{
DVECTOR pos;
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()
{
DVECTOR pos;
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;
}
/*----------------------------------------------------------------------