diff --git a/source/gfx/fdata.cpp b/source/gfx/fdata.cpp index 708858164..6155946b2 100644 --- a/source/gfx/fdata.cpp +++ b/source/gfx/fdata.cpp @@ -86,7 +86,7 @@ s16 standardFontTab[]= /* ð ñ ò ó ô õ ö ÷ */ -1, -1,FRM__242,FRM__243,FRM__244,FRM__245,FRM__246, -1, /* ø ù ú û ü ý þ ÿ */ -1,FRM__249,FRM__250,FRM__251,FRM__252,FRM__253, -1,FRM__255, }; -FontData standardFont( SPRITES_SPRITES_SPR, standardFontTab, 13, 1,1, 4 ); +FontData standardFont( SPRITES_SPRITES_SPR, standardFontTab, 13, 0,1, 4 ); /*---------------------------------------------------------------------- Function: diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 564647b25..bcb38d1a7 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -271,7 +271,7 @@ void CNpcPlatform::init() m_tiltVelocity = 0; m_tiltable = false; - setCollisionSize(80,40); + setCollisionSize(80,50); //setCollisionSize( 200, 20 ); m_layerCollision = NULL; @@ -462,6 +462,9 @@ void CNpcPlatform::think(int _frames) processTimer( _frames ); +//pkg +// + CPlatformThing::think(_frames); } @@ -581,9 +584,16 @@ void CNpcPlatform::collidedWith( CThing *_thisThing ) { if ( m_detectCollision && m_isActive ) { - CPlayer *player = (CPlayer *) _thisThing; + CPlayer *player; + DVECTOR playerPos; + CRECT collisionArea; - if ( player->getHasPlatformCollided() ) + // Only interested in SBs feet colliding with the box (pkg) + player=(CPlayer*)_thisThing; + playerPos=player->getPos(); + collisionArea=getCollisionArea(); + if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&& + playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2) { player->setPlatform( this ); @@ -630,6 +640,31 @@ void CNpcPlatform::render() // setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16); // setRGB0(F4,127,127,64); // AddPrimToList(F4,2); + +#ifdef __USER_paul__ + DVECTOR centre; + CRECT area; + int halfLength; + int x1,y1,x2,y2; + + centre=getCollisionCentre(); + area=getCollisionArea(); + halfLength=(area.x2-area.x1)/2; + + x1=-halfLength*mcos(getCollisionAngle()&4095)>>12; + y1=-halfLength*msin(getCollisionAngle()&4095)>>12; + x2=+halfLength*mcos(getCollisionAngle()&4095)>>12; + y2=+halfLength*msin(getCollisionAngle()&4095)>>12; + + centre.vx-=offset.vx; + centre.vy-=offset.vy; + x1+=centre.vx; + y1+=centre.vy; + x2+=centre.vx; + y2+=centre.vy; + + DrawLine(x1,y1,x2,y2,0,255,0,0); +#endif } } } @@ -637,6 +672,7 @@ void CNpcPlatform::render() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef REMOVETHIS s32 CNpcPlatform::getNewYPos(CThing *_thisThing) { CRECT thisRect; @@ -742,9 +778,11 @@ s32 CNpcPlatform::getNewYPos(CThing *_thisThing) return( highestY ); } +#endif // REMOVETHIS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +#ifdef REMOVETHIS int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) { DVECTOR pos,thisThingPos; @@ -891,6 +929,7 @@ int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) return collided; } +#endif // REMOVETHIS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -901,6 +940,20 @@ void CNpcPlatform::setTiltable( bool isTiltable ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y) +{ + DVECTOR centre; + int y; + + // Rotate backwards to find height + centre=getCollisionCentre(); + y=(centre.vx-_x)*msin(-getCollisionAngle()&4095)>>12; + + return (centre.vy-_y)+y; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos ) { DVECTOR newPos; diff --git a/source/platform/platform.h b/source/platform/platform.h index f81afe737..5a45fa89b 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -68,8 +68,11 @@ public: void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} void setType( NPC_PLATFORM_UNIT_TYPE newType ) {m_type = newType;} void setTypeFromMapEdit( u16 newType ); - virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); +#ifdef REMOVETHIS +// virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); virtual s32 getNewYPos( CThing *_thisThing ); +#endif + int getHeightFromPlatformAtPosition(int _x,int _y); void setTiltable( bool isTiltable ); void addWaypoint( s32 xPos, s32 yPos ); void setGraphic( sThingPlatform *ThisPlatform ); diff --git a/source/player/player.cpp b/source/player/player.cpp index 587403244..b178ca4dc 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -73,8 +73,13 @@ #include "gfx\sprbank.h" #endif +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + + // to be removed -#include "gfx\tpage.h" +//#include "gfx\tpage.h" /* Std Lib @@ -338,16 +343,23 @@ if(newmode!=-1) newmode=-1; } - if(isOnPlatform()) + CThing *platform; + platform=isOnPlatform(); + if(platform) { - shove(m_platform->getPosDelta()); + DVECTOR posDelta; + posDelta=platform->getPosDelta(); + if(((CNpcPlatform*)platform)->getHeightFromPlatformAtPosition(Pos.vx+posDelta.vx,Pos.vy+posDelta.vy)==0) + { + shove(posDelta); + } } + + for(i=0;i<_frames;i++) { // Think updatePadInput(); -// s_modes[m_currentMode].m_modeControl->think(); -// m_currentStateClass->think(this); m_currentPlayerModeClass->think(); // Powerups @@ -647,6 +659,8 @@ for(int i=0;igetFrameHeader(*frames)->H; for(i=5;i>0;i--) { ft4=m_spriteBank->printFT4(*frames++,x,y,0,0,5); @@ -654,7 +668,7 @@ for(int i=0;igetHeightFromGround(_x,_y,_maxHeight); + + platform=isOnPlatform(); + if(platform) { - CThing *platform = isOnPlatform(); - height = platform->getNewYPos( this ) - Pos.vy; + int platformHeight; + platformHeight=((CNpcPlatform*)platform)->getHeightFromPlatformAtPosition(_x,_y); + if(platformHeight>_maxHeight)platformHeight=_maxHeight; + else if(platformHeight<-_maxHeight)platformHeight=-_maxHeight; - int groundHeight = m_layerCollision->getHeightFromGround(_x,_y,_maxHeight); - - if ( groundHeight < height ) + if(height>platformHeight) { - height = groundHeight; - clearPlatform(); + height=platformHeight; } } - else - { - height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight); - } + return height; } @@ -935,7 +948,7 @@ void CPlayer::respawn() ---------------------------------------------------------------------- */ void CPlayer::renderSb(DVECTOR *_pos,int _animNo,int _animFrame) { - m_actorGfx->Render(*_pos,_animNo,_animFrame,m_facing==FACING_RIGHT?0:1); +//pkg m_actorGfx->Render(*_pos,_animNo,_animFrame,m_facing==FACING_RIGHT?0:1); } @@ -1212,7 +1225,6 @@ int CPlayer::moveVertical(int _moveDistance) { DVECTOR pos; int hitGround; -// int colHeight; pos=Pos; hitGround=false; @@ -1233,81 +1245,23 @@ int CPlayer::moveVertical(int _moveDistance) 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) + if(_moveDistance<0&& + (m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& + getHeightFromGround(pos.vx,pos.vy+_moveDistance)<=0) { 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; - */ } /*---------------------------------------------------------------------- @@ -1373,51 +1327,37 @@ int CPlayer::moveHorizontal(int _moveDistance) pos.vy+=colHeight; } } - else + else if(colHeight>0) // Lets you jump through platforms from below { - // In the air - /* - if((getLayerCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)==(6<getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& + getHeightFromGround(pos.vx+_moveDistance,pos.vy,5)<0) { - // Hit an impassable block - pos.vx&=0xfff0; - if(_moveDistance>0) + // Stop at the edge of the obstruction + int dir,vx,cx,i; + if(_moveDistance<0) { - pos.vx+=15; + dir=-1; + vx=-_moveDistance; } + else + { + dir=+1; + vx=_moveDistance; + } + cx=pos.vx; + for(i=0;i=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;i