This commit is contained in:
Paul 2001-02-16 22:53:16 +00:00
parent deeafdb0d1
commit 301deb6d6c
7 changed files with 52 additions and 74 deletions

View file

@ -116,6 +116,7 @@ u8 c;
if (c) ThisTile.Ofs[X]++; if (c) ThisTile.Ofs[X]++;
if (DebugOn) printf("%i",c); if (DebugOn) printf("%i",c);
} }
if(ThisTile.Ofs[X])ThisTile.Ofs[X]++; // (pkg)
if (DebugOn) printf("\t%i \n",ThisTile.Ofs[X]); if (DebugOn) printf("\t%i \n",ThisTile.Ofs[X]);
} }
if (DebugOn) printf("\n"); if (DebugOn) printf("\n");

View file

@ -44,6 +44,7 @@ int CLayerCollision::getHeightFromGround(int _x,int _y,int _maxHeight)
int mapX,mapY,xFraction,yFraction; int mapX,mapY,xFraction,yFraction;
int distanceFromGround; int distanceFromGround;
int colHeight; int colHeight;
int maxHeightToCheck;
mapX=_x>>4; mapX=_x>>4;
mapY=(_y>>4)*MapWidth; mapY=(_y>>4)*MapWidth;
@ -51,38 +52,43 @@ int CLayerCollision::getHeightFromGround(int _x,int _y,int _maxHeight)
yFraction=16-(_y&0x0f); yFraction=16-(_y&0x0f);
distanceFromGround=0; distanceFromGround=0;
colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];if(Map[mapX+mapY])colHeight++; colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];
if(colHeight) if(colHeight)
{ {
// Inside a collision block.. find the nearest ground above this point // Inside a collision block.. find the nearest ground above this point
maxHeightToCheck=-_maxHeight-16; // Need to check one block more incase we cross onto a new block
while(colHeight==16) while(colHeight==16)
{ {
_y-=16; _y-=16;
mapY-=MapWidth; mapY-=MapWidth;
distanceFromGround-=16; distanceFromGround-=16;
if(distanceFromGround<=-_maxHeight) if(distanceFromGround<=maxHeightToCheck)
{ {
return -_maxHeight; return -_maxHeight;
} }
colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];if(Map[mapX+mapY])colHeight++; colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];
} }
distanceFromGround+=yFraction-colHeight; distanceFromGround+=yFraction-colHeight;
if(distanceFromGround<-_maxHeight)distanceFromGround=-_maxHeight;
} }
else else
{ {
// Not inside a collision block.. find the nearest ground below this point // Not inside a collision block.. find the nearest ground below this point
maxHeightToCheck=_maxHeight+16; // Need to check one block more incase we cross onto a new block
while(colHeight==0) while(colHeight==0)
{ {
_y+=16; _y+=16;
mapY+=MapWidth; mapY+=MapWidth;
distanceFromGround+=16; distanceFromGround+=16;
if(distanceFromGround>=_maxHeight) if(distanceFromGround>=maxHeightToCheck)
{ {
return _maxHeight; return _maxHeight;
} }
colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];if(Map[mapX+mapY])colHeight++; colHeight=m_collisionTable[(Map[mapX+mapY]*16)+xFraction];
} }
distanceFromGround+=yFraction-colHeight; distanceFromGround+=yFraction-colHeight;
if(distanceFromGround>_maxHeight)distanceFromGround=_maxHeight;
} }
return distanceFromGround; return distanceFromGround;

View file

@ -1,4 +1,3 @@
char buf[100];
/*========================================================================= /*=========================================================================
player.cpp player.cpp
@ -233,7 +232,6 @@ void CPlayer::shutdown()
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int newmode=-1; int newmode=-1;
//DVECTOR pos;
void CPlayer::think(int _frames) void CPlayer::think(int _frames)
{ {
int i; int i;
@ -252,7 +250,6 @@ if(newmode!=-1)
newmode=-1; newmode=-1;
} }
if(_frames>3)_frames=3;
for(i=0;i<_frames;i++) for(i=0;i<_frames;i++)
{ {
// Think // Think
@ -262,15 +259,16 @@ if(_frames>3)_frames=3;
thinkHorizontalMovement(); thinkHorizontalMovement();
#ifdef __USER_paul__ #ifdef __USER_paul__
char buf[100];
sprintf(buf,"%03d (%02d) ,%03d (%02d) = dfg:%+02d",Pos.vx,Pos.vx&0x0f,Pos.vy,Pos.vy&0x0f,m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy)); sprintf(buf,"%03d (%02d) ,%03d (%02d) = dfg:%+02d",Pos.vx,Pos.vx&0x0f,Pos.vy,Pos.vy&0x0f,m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy));
s_debugFont.print(40,40,buf); s_debugFont.print(40,40,buf);
#endif #endif
if(Pos.vx<16)Pos.vx=16; if(Pos.vx<64)Pos.vx=64;
else if(Pos.vx>m_mapEdge.vx-16)Pos.vx=m_mapEdge.vx-16; else if(Pos.vx>m_mapEdge.vx-64)Pos.vx=m_mapEdge.vx-64;
if(Pos.vy<16)Pos.vy=16; if(Pos.vy<64)Pos.vy=64;
else if(Pos.vy>m_mapEdge.vy-16)Pos.vy=m_mapEdge.vy-16; else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64;
// Flashing.. // Flashing..
if(m_invincibleFrameCount) if(m_invincibleFrameCount)
@ -368,7 +366,7 @@ m_cameraOffset.vy=MAP2D_CENTRE_Y+((MAP2D_BLOCKSTEPSIZE*(-m_cameraScrollPos.vy))>
void CPlayer::thinkVerticalMovement() void CPlayer::thinkVerticalMovement()
{ {
int colHeight; int colHeight;
colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy); colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy,1);
if(colHeight>=0) if(colHeight>=0)
{ {
// Above or on the ground // Above or on the ground
@ -376,7 +374,7 @@ void CPlayer::thinkVerticalMovement()
if(m_moveVel.vy>0) if(m_moveVel.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=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy+(m_moveVel.vy>>VELOCITY_SHIFT)); colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy+(m_moveVel.vy>>VELOCITY_SHIFT),PLAYER_TERMINAL_VELOCITY+1);
if(colHeight<=0) if(colHeight<=0)
{ {
// Just hit the ground // Just hit the ground
@ -449,10 +447,11 @@ void CPlayer::thinkHorizontalMovement()
{ {
if(m_moveVel.vx) if(m_moveVel.vx)
{ {
if(m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy)==0) int colHeight;
colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy,5);
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
int colHeight;
colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy); colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy);
if(colHeight<-8) if(colHeight<-8)
{ {
@ -499,8 +498,9 @@ void CPlayer::thinkHorizontalMovement()
else else
{ {
// In the air // In the air
int colHeight; if(!(colHeight<0&&m_currentState==STATE_JUMP)) // Lets you jump through platforms from below
colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy); {
colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.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
@ -528,6 +528,7 @@ void CPlayer::thinkHorizontalMovement()
m_moveVel.vx=0; m_moveVel.vx=0;
} }
} }
}
Pos.vx+=m_moveVel.vx>>VELOCITY_SHIFT; Pos.vx+=m_moveVel.vx>>VELOCITY_SHIFT;
} }
} }
@ -792,27 +793,6 @@ PLAYERINPUT CPlayer::getPadInputDown()
} }
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CPlayer::isOnSolidGround()
{
return false;
/*
ASSERT(m_layerCollision);
int collHeight;
collHeight=m_layerCollision->Get(Pos.vx,Pos.vy);
// PAUL_DBGMSG("%04d,%04d=%02d",Pos.vx,Pos.vy,collHeight);
return collHeight;
*/
}
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: Purpose:
@ -823,7 +803,7 @@ int slip=false;
int CPlayer::isOnSlippySurface() int CPlayer::isOnSlippySurface()
{ {
return false; return false;
return slip&&isOnSolidGround(); // return slip&&isOnSolidGround();
} }
@ -836,23 +816,20 @@ return false;
player is hanging player is hanging
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int csize=15; int csize=15;
int cheight=15;
int CPlayer::isOnEdge() int CPlayer::isOnEdge()
{ {
return false;
/*
int ret=0; int ret=0;
ASSERT(m_layerCollision); if(m_layerCollision->getHeightFromGround(Pos.vx-csize,Pos.vy,cheight+1)>cheight)
if(!m_layerCollision->Get(Pos.vx-csize,Pos.vy))
{ {
ret=FACING_LEFT; ret=FACING_LEFT;
} }
else if(!m_layerCollision->Get(Pos.vx+csize,Pos.vy)) else if(m_layerCollision->getHeightFromGround(Pos.vx+csize,Pos.vy,cheight+1)>cheight)
{ {
ret=FACING_RIGHT; ret=FACING_RIGHT;
} }
return ret; return ret;
*/
} }
@ -864,11 +841,11 @@ return false;
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int CPlayer::canMoveLeft() int CPlayer::canMoveLeft()
{ {
return m_layerCollision->getHeightFromGround(Pos.vx-1,Pos.vy)>-8?true:false; return m_layerCollision->getHeightFromGround(Pos.vx-1,Pos.vy,16)>-8?true:false;
} }
int CPlayer::canMoveRight() int CPlayer::canMoveRight()
{ {
return m_layerCollision->getHeightFromGround(Pos.vx+1,Pos.vy)>-8?true:false; return m_layerCollision->getHeightFromGround(Pos.vx+1,Pos.vy,16)>-8?true:false;
} }

View file

@ -186,7 +186,6 @@ protected:
PLAYERINPUT getPadInputDown(); PLAYERINPUT getPadInputDown();
// Collision // Collision
int isOnSolidGround();
int isOnSlippySurface(); int isOnSlippySurface();
int isOnEdge(); int isOnEdge();
int canMoveLeft(); int canMoveLeft();

View file

@ -252,10 +252,6 @@ int CPlayerState::getPadInputDown(CPlayer *_player)
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
int CPlayerState::isOnSolidGround(CPlayer *_player)
{
return _player->isOnSolidGround();
}
int CPlayerState::isOnEdge(class CPlayer *_player) int CPlayerState::isOnEdge(class CPlayer *_player)
{ {
return _player->isOnEdge(); return _player->isOnEdge();

View file

@ -58,7 +58,6 @@ protected:
int getPadInputHeld(class CPlayer *_player); int getPadInputHeld(class CPlayer *_player);
int getPadInputDown(class CPlayer *_player); int getPadInputDown(class CPlayer *_player);
int isOnSolidGround(class CPlayer *_player);
int isOnEdge(class CPlayer *_player); int isOnEdge(class CPlayer *_player);
int canMoveLeft(class CPlayer *_player); int canMoveLeft(class CPlayer *_player);
int canMoveRight(class CPlayer *_player); int canMoveRight(class CPlayer *_player);

Binary file not shown.