This commit is contained in:
Charles 2001-04-04 16:51:04 +00:00
parent d2e6f3b5f3
commit c86973cc8c
6 changed files with 122 additions and 57 deletions

View File

@ -75,6 +75,7 @@ void CNpcFriend::init()
//m_animPlaying = true; //m_animPlaying = true;
m_animNo = 0; m_animNo = 0;
m_frame = 0; m_frame = 0;
m_reversed = false;
DVECTOR ofs = getCollisionSize(); DVECTOR ofs = getCollisionSize();
@ -125,26 +126,16 @@ void CNpcFriend::render()
DVECTOR renderPos; DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos(); DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = ( Pos.vx + m_drawOffset.vx - offset.vx - ( VidGetScrW() >> 1 ) ) * 20; renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = ( Pos.vy + m_drawOffset.vy - offset.vy - ( VidGetScrH() >> 1 ) ) * 20; renderPos.vy = Pos.vy - offset.vy;
m_actorGfx->Render(renderPos,m_frame,m_animNo,false); if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
{
/*s32 x,y; if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
s32 scrnWidth = VidGetScrW(); {
s32 scrnHeight = VidGetScrH(); m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed);
s32 spriteWidth = m_spriteBank->getFrameWidth(FRM_BARNACLEBOY); }
s32 spriteHeight = m_spriteBank->getFrameHeight(FRM_BARNACLEBOY); }
x = Pos.vx - offset.vx - ( spriteWidth >> 1 );
y = Pos.vy - offset.vy - ( spriteHeight >> 1 );
//if ( x < -spriteWidth || y < -spriteHeight || x > scrnWidth || y > scrnHeight )
//{
//return;
//}
m_spriteBank->printFT4(FRM_BARNACLEBOY,x,y,0,0,0);*/
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1403,13 +1394,16 @@ void CNpcEnemy::render()
DVECTOR renderPos; DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos(); DVECTOR offset = CLevel::getCameraPos();
//renderPos.vx = ( Pos.vx + m_drawOffset.vx - offset.vx - ( VidGetScrW() >> 1 ) );// * 20;
//renderPos.vy = ( Pos.vy + m_drawOffset.vy - offset.vy - ( VidGetScrH() >> 1 ) );// * 20;
renderPos.vx = Pos.vx - offset.vx; renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy; renderPos.vy = Pos.vy - offset.vy;
m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed); if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
{
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
{
m_actorGfx->Render(renderPos,m_animNo,m_frame,m_reversed);
}
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -106,6 +106,7 @@ protected:
int m_animNo; int m_animNo;
CActorGfx *m_actorGfx; CActorGfx *m_actorGfx;
DVECTOR m_drawOffset; DVECTOR m_drawOffset;
bool m_reversed;
}; };
class CNpcEnemy : public CEnemyThing class CNpcEnemy : public CEnemyThing

View File

@ -189,7 +189,8 @@ CNpcEnemy::NPC_DATA CNpcEnemy::m_data[NPC_UNIT_TYPE_MAX] =
ACTORS_CLAM_SBK, ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP, ANIM_CLAM_SIDESNAP,
NPC_INIT_DEFAULT, NPC_INIT_DEFAULT,
NPC_SENSOR_FALLING_ITEM_USER_CLOSE, //NPC_SENSOR_FALLING_ITEM_USER_CLOSE,
NPC_SENSOR_NONE,
NPC_MOVEMENT_STATIC, NPC_MOVEMENT_STATIC,
NPC_MOVEMENT_MODIFIER_NONE, NPC_MOVEMENT_MODIFIER_NONE,
NPC_CLOSE_FALLING_ITEM_FALL, NPC_CLOSE_FALLING_ITEM_FALL,

View File

@ -287,43 +287,56 @@ void CGameScene::initLevel()
sThingActor **actorList = Level.getActorList(); sThingActor **actorList = Level.getActorList();
if (actorList) if (actorList)
{ {
for ( actorNum = 0 ; actorNum < Level.getActorCount() ; actorNum++ ) for ( actorNum = 0 ; actorNum < Level.getActorCount() ; actorNum++ )
{
CNpcEnemy *enemy;
enemy = new ("npc enemy") CNpcEnemy;
ASSERT(enemy);
enemy->setTypeFromMapEdit( actorList[actorNum]->Type );
enemy->init();
enemy->setLayerCollision( Level.getCollisionLayer() );
int pointNum;
u16 *PntList=(u16*)MakePtr(actorList[actorNum],sizeof(sThingActor));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
enemy->setStartPos( newXPos, newYPos );
enemy->addWaypoint( newXPos, newYPos );
if ( actorList[actorNum]->PointCount > 1 )
{ {
for ( pointNum = 1 ; pointNum < actorList[actorNum]->PointCount ; pointNum++ ) CActorPool::ACTOR_TYPE actorType = CActorPool::getActorType( actorList[actorNum]->Type );
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
enemy->addWaypoint( newXPos, newYPos ); switch ( actorType )
{
case CActorPool::ACTOR_ENEMY_NPC:
{
CNpcEnemy *enemy;
enemy = new ("npc enemy") CNpcEnemy;
ASSERT(enemy);
enemy->setTypeFromMapEdit( actorList[actorNum]->Type );
enemy->init();
enemy->setLayerCollision( Level.getCollisionLayer() );
int pointNum;
u16 *PntList=(u16*)MakePtr(actorList[actorNum],sizeof(sThingActor));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
enemy->setStartPos( newXPos, newYPos );
enemy->addWaypoint( newXPos, newYPos );
if ( actorList[actorNum]->PointCount > 1 )
{
for ( pointNum = 1 ; pointNum < actorList[actorNum]->PointCount ; pointNum++ )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
enemy->addWaypoint( newXPos, newYPos );
}
}
enemy->postInit();
break;
}
default:
break;
} }
} }
enemy->postInit();
}
} }
// Song is loaded/dumped by the level, and played from here. This just gives some // Song is loaded/dumped by the level, and played from here. This just gives some
// better timing over when it starts (pkg) // better timing over when it starts (pkg)

View File

@ -12,6 +12,50 @@
#include <dstructs.h> #include <dstructs.h>
/*****************************************************************************/
CActorPool::ACTOR_TYPE CActorPool::actorType[38] =
{
ACTOR_PLAYER, //SpongeBob=0
ACTOR_FRIEND_NPC, //BarnacleBoy=1
ACTOR_FRIEND_NPC, //Gary=2
ACTOR_FRIEND_NPC, //Krusty=3
ACTOR_FRIEND_NPC, //MermaidMan=4
ACTOR_FRIEND_NPC, //Patrick=5
ACTOR_FRIEND_NPC, //Sandy=6
ACTOR_FRIEND_NPC, //Squidward=7
ACTOR_FRIEND_NPC, //Plankton=8
ACTOR_UNKNOWN,
ACTOR_ENEMY_NPC, //SmallJellyfish-Level1=10
ACTOR_ENEMY_NPC, //SmallJellyfish-Level2=11
ACTOR_ENEMY_NPC, //Motherjellyfish=12
ACTOR_ENEMY_NPC, //Anenome-Level1=13
ACTOR_ENEMY_NPC, //SpikeyAnenome=14
ACTOR_ENEMY_NPC, //Anenome-Level3=15
ACTOR_ENEMY_NPC, //BabyOctopus=16
ACTOR_ENEMY_NPC, //Ballblob=17
ACTOR_ENEMY_NPC, //Boogermonster=18
ACTOR_ENEMY_NPC, //Caterpillar=19
ACTOR_ENEMY_NPC, //Clam-Level1=20
ACTOR_ENEMY_NPC, //Clam-Level2=21
ACTOR_ENEMY_NPC, //Eyeball=22
ACTOR_ENEMY_NPC, //Flamingskull=23
ACTOR_ENEMY_NPC, //FlyingDutchman=24
ACTOR_ENEMY_NPC, //Ghost=25
ACTOR_ENEMY_NPC, //GiantWorm=26
ACTOR_ENEMY_NPC, //HermitCrab=27
ACTOR_ENEMY_NPC, //IronDogFish=28
ACTOR_ENEMY_NPC, //PuffaFish=29
ACTOR_ENEMY_NPC, //SeaSnake=30
ACTOR_ENEMY_NPC, //Sharkman=31
ACTOR_ENEMY_NPC, //SharkSub=32
ACTOR_ENEMY_NPC, //Skeletalfish=33
ACTOR_ENEMY_NPC, //SpiderCrab=34
ACTOR_ENEMY_NPC, //Squiddart=35
ACTOR_ENEMY_NPC, //Stomper=36
ACTOR_ENEMY_NPC, //DustDevil=37
};
/*****************************************************************************/ /*****************************************************************************/
CActorGfx *CActorPool::ActorList[CActorPool::MAX_ACTORS]; CActorGfx *CActorPool::ActorList[CActorPool::MAX_ACTORS];
u8 CActorPool::UnpackBuffer[CActorPool::MAX_ACTOR_SIZE]; u8 CActorPool::UnpackBuffer[CActorPool::MAX_ACTOR_SIZE];

View File

@ -47,6 +47,14 @@ public:
MAX_ACTOR_SIZE=128*128, MAX_ACTOR_SIZE=128*128,
}; };
enum ACTOR_TYPE
{
ACTOR_PLAYER = 0,
ACTOR_FRIEND_NPC = 1,
ACTOR_ENEMY_NPC,
ACTOR_UNKNOWN,
};
static void Init(); static void Init();
static void AddActor(FileEquate Filename) {GetActor(Filename);} static void AddActor(FileEquate Filename) {GetActor(Filename);}
@ -55,12 +63,16 @@ static void DumpActors();
static u8 UnpackBuffer[MAX_ACTOR_SIZE]; static u8 UnpackBuffer[MAX_ACTOR_SIZE];
static ACTOR_TYPE getActorType( int actorNum ) {return actorType[actorNum];}
private: private:
static int FindIdx(FileEquate Filename); static int FindIdx(FileEquate Filename);
static int FindFreeIdx(); static int FindFreeIdx();
static CActorGfx *ActorList[MAX_ACTORS]; static CActorGfx *ActorList[MAX_ACTORS];
static ACTOR_TYPE actorType[38];
}; };
/*****************************************************************************/ /*****************************************************************************/