This commit is contained in:
Charles 2001-04-27 15:09:10 +00:00
parent 5c2faa793b
commit 02eafd0a46
15 changed files with 160 additions and 273 deletions

View file

@ -15,76 +15,80 @@
#include "friend\friend.h"
#endif
#ifndef __ANIM_SQUIDWARD_HEADER__
#include <ACTOR_SQUIDWARD_Anim.h>
#endif
CNpcFriend::NPC_FRIEND_DATA CNpcFriend::m_data[NPC_FRIEND_UNIT_TYPE_MAX] =
{
{ // NPC_FRIEND_BARNACLE_BOY
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_GARY
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_KRUSTY
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_MERMAID_MAN
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_PATRICK
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_SANDY_CHEEKS
ACTORS_CLAM_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
0,
},
{ // NPC_FRIEND_SQUIDWARD
ACTORS_SQUIDWARD_SBK,
NPC_FRIEND_MOVEMENT_STATIC,
true,
3,
128,
false,
DAMAGE__HIT_ENEMY,
ANIM_SQUIDWARD_IDLEBREATHE,
},
};

View file

@ -11,8 +11,8 @@
===========================================================================*/
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#ifndef __FRIEND_FGARY_H__
#include "friend\fgary.h"
#endif
#ifndef __GAME_GAME_H__
@ -20,8 +20,10 @@
#endif
void CNpcFriend::processGaryMovement( int _frames )
void CNpcGaryFriend::think( int _frames )
{
CNpcThing::think(_frames);
s8 multiplier = -1 + ( 2 * m_extension );
s32 maxHeight = 20;
s32 fallSpeed = 3;

View file

@ -31,6 +31,10 @@
#include "utils\utils.h"
#endif
#ifndef __FRIEND_FSQUID_H__
#include "friend\fsquid.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Friend NPCs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -45,7 +49,7 @@ CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor)
{
case CNpcFriend::NPC_FRIEND_SQUIDWARD:
{
friendNpc = new ("squidward") CNpcFriend;
friendNpc = new ("squidward") CNpcSquidwardFriend;
break;
}
@ -97,8 +101,8 @@ void CNpcFriend::init()
m_actorGfx = CActorPool::GetActor( (FileEquate) m_data[m_type].skelType );
//m_animPlaying = true;
m_animNo = 0;
m_animPlaying = true;
m_animNo = m_data[m_type].idleAnim;
m_frame = 0;
m_reversed = false;
@ -134,16 +138,53 @@ void CNpcFriend::think(int _frames)
{
CNpcThing::think(_frames);
switch( m_data[m_type].movementFunc )
if ( m_animPlaying )
{
case NPC_FRIEND_MOVEMENT_GARY:
processGaryMovement( _frames );
s32 frameCount;
break;
frameCount = m_actorGfx->getFrameCount( m_animNo );
case NPC_FRIEND_MOVEMENT_STATIC:
default:
break;
s32 frameShift = ( _frames << 8 ) >> 1;
if ( ( frameCount << 8 ) - m_frame > frameShift )
{
m_frame += frameShift;
}
else
{
m_frame = ( frameCount - 1 ) << 8;
m_animPlaying = false;
}
}
s32 fallSpeed = 3;
s8 yMovement = fallSpeed * _frames;
s8 groundHeight;
// check vertical collision
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
if ( groundHeight <= 0 )
{
// make sure we are on the ground, not below it
Pos.vy += groundHeight;
}
else
{
// above ground
if ( groundHeight < yMovement )
{
// colliding with ground
Pos.vy += groundHeight;
}
else
{
Pos.vy += yMovement;
}
}
}
@ -164,7 +205,7 @@ void CNpcFriend::render()
{
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
{
m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed);
m_actorGfx->Render(renderPos,m_animNo,(m_frame>>8),m_reversed);
}
}
}

View file

@ -40,7 +40,7 @@ public:
void init();
void init( DVECTOR initPos );
void shutdown();
void think(int _frames);
virtual void think(int _frames);
void render();
void processEvent( GAME_EVENT evt, CThing *sourceThing );
void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;}
@ -49,25 +49,19 @@ public:
static CNpcFriend *Create(sThingActor *ThisActor);
static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType );
private:
protected:
class CLayerCollision *m_layerCollision;
protected:
enum NPC_FRIEND_MOVEMENT_FUNC
{
NPC_FRIEND_MOVEMENT_STATIC = 0,
NPC_FRIEND_MOVEMENT_GARY = 1,
};
typedef struct NPC_FRIEND_DATA_TYPE
{
int skelType;
NPC_FRIEND_MOVEMENT_FUNC movementFunc;
bool canTalk;
u8 speed;
u16 turnSpeed;
bool detectCollision;
DAMAGE_TYPE damageToUserType;
u16 idleAnim;
}
NPC_FRIEND_DATA;
@ -96,6 +90,7 @@ protected:
int m_frame;
int m_animNo;
u8 m_animPlaying;
CActorGfx *m_actorGfx;
DVECTOR m_drawOffset;
bool m_reversed;

25
source/friend/fsquid.h Normal file
View file

@ -0,0 +1,25 @@
/*=========================================================================
fsquid.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __FRIEND_FSQUID_H__
#define __FRIEND_FSQUID_H__
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
class CNpcSquidwardFriend : public CNpcFriend
{
};
#endif