This commit is contained in:
parent
461123580e
commit
0cb7d8d491
@ -179,7 +179,6 @@ static const char *s_modeText[NUM_PLAYERMODES]=
|
||||
#endif
|
||||
|
||||
|
||||
int s_health;
|
||||
int s_screenPos;
|
||||
DVECTOR m_cameraScrollPos={0,600};
|
||||
|
||||
@ -458,19 +457,23 @@ m_fontBank->print(40,40,posBuf);
|
||||
|
||||
x=healthx;
|
||||
y=healthy;
|
||||
if(s_health)
|
||||
if(m_health==0||m_healthReactFrames)
|
||||
{
|
||||
frames=s_fullHealthFrames;
|
||||
if(m_healthReactFrames)
|
||||
{
|
||||
m_healthReactFrames--;
|
||||
}
|
||||
frames=s_emptyHealthFrames;
|
||||
}
|
||||
else
|
||||
{
|
||||
frames=s_emptyHealthFrames;
|
||||
frames=s_fullHealthFrames;
|
||||
}
|
||||
|
||||
for(i=5;i>0;i--)
|
||||
{
|
||||
ft4=m_spriteBank->printFT4(*frames++,x,y,0,0,5);
|
||||
if(i>s_health)
|
||||
if(i>m_health)
|
||||
{
|
||||
setRGB0(ft4,healthr,healthg,healthb);
|
||||
}
|
||||
@ -538,10 +541,10 @@ int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight)
|
||||
---------------------------------------------------------------------- */
|
||||
void CPlayer::addHealth(int _health)
|
||||
{
|
||||
s_health+=_health;
|
||||
if(s_health>MAX_HEALTH)
|
||||
m_health+=_health;
|
||||
if(m_health>MAX_HEALTH)
|
||||
{
|
||||
s_health=MAX_HEALTH;
|
||||
m_health=MAX_HEALTH;
|
||||
}
|
||||
}
|
||||
|
||||
@ -670,7 +673,8 @@ void CPlayer::respawn()
|
||||
setMode(PLAYER_MODE_BASICUNARMED);
|
||||
}
|
||||
|
||||
s_health=MAX_HEALTH;
|
||||
m_health=MAX_HEALTH;
|
||||
m_healthReactFrames=0;
|
||||
m_invincibleFrameCount=INVINCIBLE_FRAMES__START;
|
||||
Pos=m_respawnPos;
|
||||
|
||||
@ -743,10 +747,11 @@ void CPlayer::takeDamage(DAMAGE_TYPE _damage)
|
||||
#ifdef __VERSION_DEBUG__
|
||||
if(invincibleSponge){m_invincibleFrameCount=INVINCIBLE_FRAMES__HIT;return;}
|
||||
#endif
|
||||
if(s_health)
|
||||
if(m_health)
|
||||
{
|
||||
m_invincibleFrameCount=INVINCIBLE_FRAMES__HIT;
|
||||
s_health--;
|
||||
m_healthReactFrames=10;
|
||||
m_health--;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -89,21 +89,65 @@ void CPlayerModeNet::think()
|
||||
{
|
||||
m_netFrame=0;
|
||||
m_netting=true;
|
||||
switch(m_netState)
|
||||
{
|
||||
case NET_STATE__EMPTY:
|
||||
m_netState=NET_STATE__FULL;
|
||||
break;
|
||||
case NET_STATE__FULL:
|
||||
m_netState=NET_STATE__EMPTY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Netting?
|
||||
if(m_netting)
|
||||
{
|
||||
//!!! m_player->setAnimNo(ANIM_SPONGEBOB_KARATE);
|
||||
switch(m_netState)
|
||||
{
|
||||
case NET_STATE__EMPTY:
|
||||
{
|
||||
DVECTOR playerPos;
|
||||
int playerFacing;
|
||||
CRECT netRect;
|
||||
CThing *thing;
|
||||
|
||||
playerPos=m_player->getPos();
|
||||
playerFacing=m_player->getFacing();
|
||||
|
||||
netRect.x1=playerPos.vx-20;
|
||||
netRect.y1=playerPos.vy-20-40;
|
||||
netRect.x2=playerPos.vx+20;
|
||||
netRect.y2=playerPos.vy+20-40;
|
||||
|
||||
thing=CThingManager::checkCollisionAreaAgainstThings(&netRect,CThing::TYPE_ENEMY,false);
|
||||
while(thing)
|
||||
{
|
||||
// if((CEnemy*)thing)->canBeCaughtByNet()) ( or whatever.. )
|
||||
if(1) // just to stop the complier complaining until the above line can be put it..
|
||||
{
|
||||
PAUL_DBGMSG("Caught!");
|
||||
//((CEnemy*)thing)->caughtWithNet(); ( or whatever.. )
|
||||
m_netState=NET_STATE__JUST_CAUGHT_SOMETHING;
|
||||
thing=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
thing=CThingManager::checkCollisionAreaAgainstThings(&netRect,CThing::TYPE_ENEMY,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_STATE__JUST_CAUGHT_SOMETHING:
|
||||
break;
|
||||
|
||||
case NET_STATE__FULL:
|
||||
if(m_netFrame==0)
|
||||
{
|
||||
// Launch projectile at halfway through the swing..
|
||||
PAUL_DBGMSG("Released!");
|
||||
// new cprojectile ( or whatever.. )
|
||||
m_netState=NET_STATE__JUST_LAUNCHED_SOMETHING;
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_STATE__JUST_LAUNCHED_SOMETHING:
|
||||
break;
|
||||
}
|
||||
|
||||
//!!! m_player->setAnimNo(ANIM_SPONGEBOB_KARATE);
|
||||
m_player->setAnimNo(ANIM_SPONGEBOB_FIRE);
|
||||
m_player->setAnimFrame(m_netFrame);
|
||||
m_netFrame++;
|
||||
@ -112,6 +156,15 @@ void CPlayerModeNet::think()
|
||||
m_player->setAnimNo(m_savedAnimNo);
|
||||
m_player->setAnimFrame(m_savedAnimFrame);
|
||||
m_netting=false;
|
||||
|
||||
if(m_netState==NET_STATE__JUST_CAUGHT_SOMETHING)
|
||||
{
|
||||
m_netState=NET_STATE__FULL;
|
||||
}
|
||||
else if(m_netState==NET_STATE__JUST_LAUNCHED_SOMETHING)
|
||||
{
|
||||
m_netState=NET_STATE__EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
netstate=m_netState;
|
||||
|
@ -48,7 +48,9 @@ private:
|
||||
typedef enum
|
||||
{
|
||||
NET_STATE__EMPTY,
|
||||
NET_STATE__JUST_CAUGHT_SOMETHING,
|
||||
NET_STATE__FULL,
|
||||
NET_STATE__JUST_LAUNCHED_SOMETHING,
|
||||
} NetState;
|
||||
|
||||
int canSwingNetFromThisState();
|
||||
|
@ -256,6 +256,48 @@ void CThingManager::processEventAllThings(GAME_EVENT _event,CThing *_sourceThin
|
||||
}
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose: Searches through a list of things to check for collision against an area.
|
||||
The first time this is called, _continue should be false. If no colliding things are found then
|
||||
NULL will be returned. If a colliding thing is found then it's address gets returned. To continue
|
||||
searching through the list for the next colliding thing, call the function again with _continue set
|
||||
to true.
|
||||
NB: This function could probly cause weird bugs if not used properly! BE AWARE!
|
||||
Params: *_area Area to check against
|
||||
_type Type of thing to search for
|
||||
_continue If false then the list is searched from the start, if true then the search continues
|
||||
from the last thing that was found ( um.. see above )
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
CThing *CThingManager::checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue)
|
||||
{
|
||||
static CThing *thing=NULL;
|
||||
|
||||
ASSERT(_type<CThing::MAX_TYPE);
|
||||
|
||||
if(_continue)
|
||||
{
|
||||
ASSERT(thing);
|
||||
thing=thing->m_nextThing;
|
||||
}
|
||||
else
|
||||
{
|
||||
thing=s_thingLists[_type];
|
||||
}
|
||||
while(thing)
|
||||
{
|
||||
if(thing->canCollide()&&
|
||||
thing->checkCollisionAgainstArea(_area))
|
||||
{
|
||||
return thing;
|
||||
}
|
||||
thing=thing->m_nextThing;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
@ -647,6 +689,29 @@ int CThing::checkCollisionAgainst(CThing *_thisThing, int _frames)
|
||||
return collided;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
Params:
|
||||
Returns:
|
||||
---------------------------------------------------------------------- */
|
||||
int CThing::checkCollisionAgainstArea(CRECT *_rect)
|
||||
{
|
||||
CRECT thisRect;
|
||||
int ret;
|
||||
|
||||
thisRect=getCollisionArea();
|
||||
ret=false;
|
||||
|
||||
if(((thisRect.x1>=_rect->x1&&thisRect.x1<=_rect->x2)||(thisRect.x2>=_rect->x1&&thisRect.x2<=_rect->x2)||(thisRect.x1<=_rect->x1&&thisRect.x2>=_rect->x2))&&
|
||||
((thisRect.y1>=_rect->y1&&thisRect.y1<=_rect->y2)||(thisRect.y2>=_rect->y1&&thisRect.y2<=_rect->y2)||(thisRect.y1<=_rect->y1&&thisRect.y2>=_rect->y2)))
|
||||
{
|
||||
ret=true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Function:
|
||||
Purpose:
|
||||
|
@ -38,6 +38,14 @@
|
||||
Structure defintions
|
||||
-------------------- */
|
||||
|
||||
// Collision rectangle definition
|
||||
typedef struct
|
||||
{
|
||||
int x1,y1,x2,y2;
|
||||
}
|
||||
CRECT;
|
||||
|
||||
|
||||
// Thing manager class
|
||||
class CThingManager
|
||||
{
|
||||
@ -49,6 +57,8 @@ public:
|
||||
static void renderAllThings();
|
||||
static void processEventAllThings(GAME_EVENT _event,class CThing *_sourceThing);
|
||||
|
||||
static CThing* checkCollisionAreaAgainstThings(CRECT *_area,int _type,int _continue);
|
||||
|
||||
protected:
|
||||
static void addToThingList(class CThing *_this);
|
||||
static void removeFromThingList(CThing *_this);
|
||||
@ -126,13 +136,6 @@ public:
|
||||
|
||||
// -- Collision --
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
int x1,y1,x2,y2;
|
||||
}
|
||||
CRECT;
|
||||
|
||||
|
||||
DVECTOR getCollisionCentre() {return m_collisionCentre;}
|
||||
int getCollisionRadius() {return m_collisionRadius;}
|
||||
CRECT getCollisionArea() {return m_collisionArea;}
|
||||
@ -143,6 +146,7 @@ public:
|
||||
|
||||
virtual int canCollide() {return true;}
|
||||
virtual int checkCollisionAgainst(CThing *_thisThing, int _frames);
|
||||
int checkCollisionAgainstArea(CRECT *_rect);
|
||||
void updateCollisionArea();
|
||||
virtual void collidedWith(CThing *_thisThing) {;}
|
||||
virtual void setHasPlatformCollided( bool newVal ) {;}
|
||||
@ -150,6 +154,8 @@ public:
|
||||
virtual s32 getNewYPos( CThing *_thisThing );
|
||||
void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;}
|
||||
void setCentreCollision(bool newCentreCollision) {m_centreCollision = newCentreCollision;}
|
||||
|
||||
|
||||
protected:
|
||||
void setCollisionSize(int _w,int _h);
|
||||
void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;}
|
||||
|
Loading…
Reference in New Issue
Block a user