From 7bbfd89bbad27f016f4c5c105b50cad9213807ab Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 25 Apr 2001 18:38:33 +0000 Subject: [PATCH] --- source/player/player.cpp | 261 +++++++++++++++++++++++++++++++++++++-- source/player/player.h | 7 +- source/player/pmdead.cpp | 12 +- source/player/pmdead.h | 4 +- source/player/pmodes.cpp | 165 +++---------------------- 5 files changed, 283 insertions(+), 166 deletions(-) diff --git a/source/player/player.cpp b/source/player/player.cpp index 114931854..56c0358b5 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -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;i0) + { + 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=-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<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;i99)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; diff --git a/source/player/pmdead.cpp b/source/player/pmdead.cpp index 6cc3a7098..108e8ee93 100644 --- a/source/player/pmdead.cpp +++ b/source/player/pmdead.cpp @@ -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]<m_metric[DEFAULT_PLAYER_PLAYER_GRAVITY]; + if(m_yVelocity>=metrics->m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<m_metric[DEFAULT_PLAYER_TERMINAL_VELOCITY]<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) + playerHasHitGround(); + } + 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) { - // 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&& - m_currentState!=STATE_BUTTFALL&&m_currentState!=STATE_BUTTBOUNCE&& - m_currentState!=STATE_JUMP) - { - // Was floating in the air.. fall! - setState(STATE_FALL); - } + // 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<isOnPlatform() && m_moveVelocity.vy >= 0 ) - { - pos.vy += colHeight; - playerHasHitGround(); - } - } - - pos.vy+=m_moveVelocity.vy>>VELOCITY_SHIFT; - m_player->setPlayerPos(&pos); } /*---------------------------------------------------------------------- @@ -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) + // If running then go to idle, otherwise leave in same state + if(m_currentState==STATE_RUN) { - // 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;igetHeightFromGround(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; - } + setState(STATE_IDLE); } - else - { - // In the air - if((m_player->getLayerCollision()->getCollisionBlock(pos.vx+(m_moveVelocity.vx>>VELOCITY_SHIFT),pos.vy)&COLLISION_TYPE_MASK)==(6<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;igetHeightFromGround(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); + m_moveVelocity.vx=0; } }