This commit is contained in:
Paul 2001-04-27 02:05:05 +00:00
parent 530aaad695
commit f0dfe1ac95
6 changed files with 123 additions and 130 deletions

View file

@ -86,7 +86,7 @@ s16 standardFontTab[]=
/* ð ñ ò ó ô õ ö ÷ */ -1, -1,FRM__242,FRM__243,FRM__244,FRM__245,FRM__246, -1, /* ð ñ ò ó ô õ ö ÷ */ -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, /* ø ù ú û ü ý þ ÿ */ -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: Function:

View file

@ -271,7 +271,7 @@ void CNpcPlatform::init()
m_tiltVelocity = 0; m_tiltVelocity = 0;
m_tiltable = false; m_tiltable = false;
setCollisionSize(80,40); setCollisionSize(80,50);
//setCollisionSize( 200, 20 ); //setCollisionSize( 200, 20 );
m_layerCollision = NULL; m_layerCollision = NULL;
@ -462,6 +462,9 @@ void CNpcPlatform::think(int _frames)
processTimer( _frames ); processTimer( _frames );
//pkg
//
CPlatformThing::think(_frames); CPlatformThing::think(_frames);
} }
@ -581,9 +584,16 @@ void CNpcPlatform::collidedWith( CThing *_thisThing )
{ {
if ( m_detectCollision && m_isActive ) 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 ); player->setPlatform( this );
@ -630,6 +640,31 @@ void CNpcPlatform::render()
// setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16); // setXYWH(F4,renderPos.vx-32,renderPos.vy-32,64,16);
// setRGB0(F4,127,127,64); // setRGB0(F4,127,127,64);
// AddPrimToList(F4,2); // 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) s32 CNpcPlatform::getNewYPos(CThing *_thisThing)
{ {
CRECT thisRect; CRECT thisRect;
@ -742,9 +778,11 @@ s32 CNpcPlatform::getNewYPos(CThing *_thisThing)
return( highestY ); return( highestY );
} }
#endif // REMOVETHIS
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef REMOVETHIS
int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
{ {
DVECTOR pos,thisThingPos; DVECTOR pos,thisThingPos;
@ -891,6 +929,7 @@ int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
return collided; 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 ) void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos )
{ {
DVECTOR newPos; DVECTOR newPos;

View file

@ -68,8 +68,11 @@ public:
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
void setType( NPC_PLATFORM_UNIT_TYPE newType ) {m_type = newType;} void setType( NPC_PLATFORM_UNIT_TYPE newType ) {m_type = newType;}
void setTypeFromMapEdit( u16 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 ); virtual s32 getNewYPos( CThing *_thisThing );
#endif
int getHeightFromPlatformAtPosition(int _x,int _y);
void setTiltable( bool isTiltable ); void setTiltable( bool isTiltable );
void addWaypoint( s32 xPos, s32 yPos ); void addWaypoint( s32 xPos, s32 yPos );
void setGraphic( sThingPlatform *ThisPlatform ); void setGraphic( sThingPlatform *ThisPlatform );

View file

@ -73,8 +73,13 @@
#include "gfx\sprbank.h" #include "gfx\sprbank.h"
#endif #endif
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
// to be removed // to be removed
#include "gfx\tpage.h" //#include "gfx\tpage.h"
/* Std Lib /* Std Lib
@ -338,16 +343,23 @@ if(newmode!=-1)
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++) for(i=0;i<_frames;i++)
{ {
// Think // Think
updatePadInput(); updatePadInput();
// s_modes[m_currentMode].m_modeControl->think();
// m_currentStateClass->think(this);
m_currentPlayerModeClass->think(); m_currentPlayerModeClass->think();
// Powerups // Powerups
@ -647,6 +659,8 @@ for(int i=0;i<NUM_LASTPOS;i++)
frames=s_fullHealthFrames; frames=s_fullHealthFrames;
} }
int ygap;
ygap=m_spriteBank->getFrameHeader(*frames)->H;
for(i=5;i>0;i--) for(i=5;i>0;i--)
{ {
ft4=m_spriteBank->printFT4(*frames++,x,y,0,0,5); ft4=m_spriteBank->printFT4(*frames++,x,y,0,0,5);
@ -654,7 +668,7 @@ for(int i=0;i<NUM_LASTPOS;i++)
{ {
setRGB0(ft4,healthr,healthg,healthb); setRGB0(ft4,healthr,healthg,healthb);
} }
y+=9; y+=ygap;
} }
} }
@ -688,25 +702,24 @@ void CPlayer::setMapSize(DVECTOR _mapSize)
int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight) int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight)
{ {
int height; int height;
DVECTOR platformPos; CThing *platform;
DVECTOR newPos;
if(isOnPlatform()) height=height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight);
platform=isOnPlatform();
if(platform)
{ {
CThing *platform = isOnPlatform(); int platformHeight;
height = platform->getNewYPos( this ) - Pos.vy; 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(height>platformHeight)
if ( groundHeight < height )
{ {
height = groundHeight; height=platformHeight;
clearPlatform();
} }
} }
else
{
height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight);
}
return height; return height;
} }
@ -935,7 +948,7 @@ void CPlayer::respawn()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayer::renderSb(DVECTOR *_pos,int _animNo,int _animFrame) 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; DVECTOR pos;
int hitGround; int hitGround;
// int colHeight;
pos=Pos; pos=Pos;
hitGround=false; hitGround=false;
@ -1233,81 +1245,23 @@ int CPlayer::moveVertical(int _moveDistance)
hitGround=true; hitGround=true;
} }
} }
/*
}
else// if(getHeightFromGround(pos.vx,pos.vy+_moveDistance,1)) else// if(getHeightFromGround(pos.vx,pos.vy+_moveDistance,1))
{ {
// Must be below ground // Must be below ground
// Are we jumping into an impassable block? // Are we jumping into an impassable block?
if(_moveDistance>0&& if(_moveDistance<0&&
(m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL) (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); pos.vy=(pos.vy&0xfff0);
_moveDistance=0; _moveDistance=0;
hitGround=true; hitGround=true;
} }
else if(isOnPlatform()&&_moveDistance>=0)
{
pos.vy+=colHeight;
hitGround=true;
}
} }
*/
pos.vy+=_moveDistance; pos.vy+=_moveDistance;
setPlayerPos(&pos); setPlayerPos(&pos);
return hitGround; 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; pos.vy+=colHeight;
} }
} }
else else if(colHeight>0) // Lets you jump through platforms from below
{ {
// In the air if((m_layerCollision->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&&
/* getHeightFromGround(pos.vx+_moveDistance,pos.vy,5)<0)
if((getLayerCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)==(6<<COLLISION_TYPE_FLAG_SHIFT))
{ {
// Hit an impassable block // Stop at the edge of the obstruction
pos.vx&=0xfff0; int dir,vx,cx,i;
if(_moveDistance>0) if(_moveDistance<0)
{ {
pos.vx+=15; dir=-1;
vx=-_moveDistance;
} }
else
{
dir=+1;
vx=_moveDistance;
}
cx=pos.vx;
for(i=0;i<vx;i++)
{
if(getHeightFromGround(cx,pos.vy)<0)
{
break;
}
cx+=dir;
}
if(i)
cx-=dir;
pos.vx=cx;
_moveDistance=0; _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;i<vx;i++)
{
if(getHeightFromGround(cx,pos.vy)<0)
{
break;
}
cx+=dir;
}
if(i)
pos.vx=cx-dir;
_moveDistance=0;
}
}
} }
pos.vx+=_moveDistance; pos.vx+=_moveDistance;
setPlayerPos(&pos); setPlayerPos(&pos);

View file

@ -55,7 +55,6 @@
CThing *CThingManager::s_thingLists[CThing::MAX_TYPE]={NULL,NULL}; CThing *CThingManager::s_thingLists[CThing::MAX_TYPE]={NULL,NULL};
int CThingManager::s_initialised=false; int CThingManager::s_initialised=false;
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: Purpose:
@ -419,7 +418,6 @@ void CThing::init()
setCollisionSize(20,20); // Some temporary defaults.. (pkg) setCollisionSize(20,20); // Some temporary defaults.. (pkg)
setCollisionCentreOffset(0,0); setCollisionCentreOffset(0,0);
m_collisionAngle = 0; m_collisionAngle = 0;
m_centreCollision = false;
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------

View file

@ -170,7 +170,6 @@ private:
CRECT m_collisionArea; CRECT m_collisionArea;
DVECTOR m_collisionCentre; DVECTOR m_collisionCentre;
s16 m_collisionAngle; s16 m_collisionAngle;
bool m_centreCollision;
DVECTOR m_newCollidedPos; DVECTOR m_newCollidedPos;
}; };