diff --git a/Utils/MkColTab/MkColTab.cpp b/Utils/MkColTab/MkColTab.cpp index 890fe30ff..1893a2fc9 100644 --- a/Utils/MkColTab/MkColTab.cpp +++ b/Utils/MkColTab/MkColTab.cpp @@ -116,6 +116,7 @@ u8 c; if (c) ThisTile.Ofs[X]++; 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("\n"); diff --git a/source/level/layercollision.cpp b/source/level/layercollision.cpp index bd53f6248..84aeaf590 100644 --- a/source/level/layercollision.cpp +++ b/source/level/layercollision.cpp @@ -44,6 +44,7 @@ int CLayerCollision::getHeightFromGround(int _x,int _y,int _maxHeight) int mapX,mapY,xFraction,yFraction; int distanceFromGround; int colHeight; + int maxHeightToCheck; mapX=_x>>4; mapY=(_y>>4)*MapWidth; @@ -51,38 +52,43 @@ int CLayerCollision::getHeightFromGround(int _x,int _y,int _maxHeight) yFraction=16-(_y&0x0f); 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) { // 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) { _y-=16; mapY-=MapWidth; distanceFromGround-=16; - if(distanceFromGround<=-_maxHeight) + if(distanceFromGround<=maxHeightToCheck) { 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; + if(distanceFromGround<-_maxHeight)distanceFromGround=-_maxHeight; + } else { // 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) { _y+=16; mapY+=MapWidth; distanceFromGround+=16; - if(distanceFromGround>=_maxHeight) + if(distanceFromGround>=maxHeightToCheck) { 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; + if(distanceFromGround>_maxHeight)distanceFromGround=_maxHeight; } return distanceFromGround; diff --git a/source/player/player.cpp b/source/player/player.cpp index 27750726b..30505a139 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -1,4 +1,3 @@ -char buf[100]; /*========================================================================= player.cpp @@ -233,7 +232,6 @@ void CPlayer::shutdown() Returns: ---------------------------------------------------------------------- */ int newmode=-1; -//DVECTOR pos; void CPlayer::think(int _frames) { int i; @@ -252,7 +250,6 @@ if(newmode!=-1) newmode=-1; } -if(_frames>3)_frames=3; for(i=0;i<_frames;i++) { // Think @@ -262,15 +259,16 @@ if(_frames>3)_frames=3; thinkHorizontalMovement(); #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)); s_debugFont.print(40,40,buf); #endif -if(Pos.vx<16)Pos.vx=16; -else if(Pos.vx>m_mapEdge.vx-16)Pos.vx=m_mapEdge.vx-16; -if(Pos.vy<16)Pos.vy=16; -else if(Pos.vy>m_mapEdge.vy-16)Pos.vy=m_mapEdge.vy-16; +if(Pos.vx<64)Pos.vx=64; +else if(Pos.vx>m_mapEdge.vx-64)Pos.vx=m_mapEdge.vx-64; +if(Pos.vy<64)Pos.vy=64; +else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64; // Flashing.. if(m_invincibleFrameCount) @@ -368,7 +366,7 @@ m_cameraOffset.vy=MAP2D_CENTRE_Y+((MAP2D_BLOCKSTEPSIZE*(-m_cameraScrollPos.vy))> void CPlayer::thinkVerticalMovement() { int colHeight; - colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy); + colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy,1); if(colHeight>=0) { // Above or on the ground @@ -376,7 +374,7 @@ void CPlayer::thinkVerticalMovement() if(m_moveVel.vy>0) { // 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) { // Just hit the ground @@ -449,10 +447,11 @@ void CPlayer::thinkHorizontalMovement() { 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 - int colHeight; colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy); if(colHeight<-8) { @@ -499,33 +498,35 @@ void CPlayer::thinkHorizontalMovement() else { // In the air - int colHeight; - colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy); - if(colHeight<0) + if(!(colHeight<0&&m_currentState==STATE_JUMP)) // Lets you jump through platforms from below { - // Stop at the edge of the obstruction - int dir,vx,cx,i; - if(m_moveVel.vx<0) + colHeight=m_layerCollision->getHeightFromGround(Pos.vx+(m_moveVel.vx>>VELOCITY_SHIFT),Pos.vy,5); + if(colHeight<0) { - dir=-1; - vx=-m_moveVel.vx>>VELOCITY_SHIFT; - } - else - { - dir=+1; - vx=m_moveVel.vx>>VELOCITY_SHIFT; - } - cx=Pos.vx; - for(i=0;igetHeightFromGround(cx,Pos.vy)<0) + // Stop at the edge of the obstruction + int dir,vx,cx,i; + if(m_moveVel.vx<0) { - break; + dir=-1; + vx=-m_moveVel.vx>>VELOCITY_SHIFT; } - cx+=dir; + else + { + dir=+1; + vx=m_moveVel.vx>>VELOCITY_SHIFT; + } + cx=Pos.vx; + for(i=0;igetHeightFromGround(cx,Pos.vy)<0) + { + break; + } + cx+=dir; + } + Pos.vx=cx-dir; + m_moveVel.vx=0; } - Pos.vx=cx-dir; - m_moveVel.vx=0; } } 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: Purpose: @@ -823,7 +803,7 @@ int slip=false; int CPlayer::isOnSlippySurface() { return false; - return slip&&isOnSolidGround(); +// return slip&&isOnSolidGround(); } @@ -836,23 +816,20 @@ return false; player is hanging ---------------------------------------------------------------------- */ int csize=15; +int cheight=15; int CPlayer::isOnEdge() { -return false; -/* int ret=0; - ASSERT(m_layerCollision); - if(!m_layerCollision->Get(Pos.vx-csize,Pos.vy)) + if(m_layerCollision->getHeightFromGround(Pos.vx-csize,Pos.vy,cheight+1)>cheight) { 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; } return ret; -*/ } @@ -864,11 +841,11 @@ return false; ---------------------------------------------------------------------- */ 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() { - 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; } diff --git a/source/player/player.h b/source/player/player.h index dd4b8ba1c..e0743c810 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -186,7 +186,6 @@ protected: PLAYERINPUT getPadInputDown(); // Collision - int isOnSolidGround(); int isOnSlippySurface(); int isOnEdge(); int canMoveLeft(); diff --git a/source/player/pstates.cpp b/source/player/pstates.cpp index efb9659f9..97889af65 100644 --- a/source/player/pstates.cpp +++ b/source/player/pstates.cpp @@ -252,10 +252,6 @@ int CPlayerState::getPadInputDown(CPlayer *_player) Params: Returns: ---------------------------------------------------------------------- */ -int CPlayerState::isOnSolidGround(CPlayer *_player) -{ - return _player->isOnSolidGround(); -} int CPlayerState::isOnEdge(class CPlayer *_player) { return _player->isOnEdge(); diff --git a/source/player/pstates.h b/source/player/pstates.h index 7e553a9b3..879b7c187 100644 --- a/source/player/pstates.h +++ b/source/player/pstates.h @@ -58,7 +58,6 @@ protected: int getPadInputHeld(class CPlayer *_player); int getPadInputDown(class CPlayer *_player); - int isOnSolidGround(class CPlayer *_player); int isOnEdge(class CPlayer *_player); int canMoveLeft(class CPlayer *_player); int canMoveRight(class CPlayer *_player); diff --git a/tools/Data/bin/MkColTab.exe b/tools/Data/bin/MkColTab.exe index ba87575b6..71065de25 100644 Binary files a/tools/Data/bin/MkColTab.exe and b/tools/Data/bin/MkColTab.exe differ