This commit is contained in:
Paul 2001-06-18 20:51:46 +00:00
parent e6ebbb57fd
commit a1375a53ac
2 changed files with 46 additions and 20 deletions

View File

@ -144,6 +144,8 @@ void CQuestItemPickup::init()
{ {
m_hiddenUntilBossDead=false; m_hiddenUntilBossDead=false;
} }
m_collected=false;
m_collectedFrameCount=0;
m_starSinRotate=0; m_starSinRotate=0;
m_starSinRadius=0; m_starSinRadius=0;
@ -190,7 +192,20 @@ void CQuestItemPickup::collidedWith(CThing *_thisThing)
{ {
if(!m_hiddenUntilBossDead) if(!m_hiddenUntilBossDead)
{ {
CBasePickup::collidedWith(_thisThing); switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
// collect((CPlayer*)_thisThing);
CSoundMediator::playSfx(sfxToPlayWhenCollected());
m_collected=true;
break;
case TYPE_NPC:
break;
default:
ASSERT(0);
}
} }
} }
@ -214,6 +229,14 @@ int CQuestItemPickup::getVisibilityRadius()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CQuestItemPickup::thinkPickup(int _frames) void CQuestItemPickup::thinkPickup(int _frames)
{ {
if(m_collected)
{
m_collectedFrameCount+=_frames;
if(m_collectedFrameCount>100)
{
collect(NULL);
}
}
if(!m_hiddenUntilBossDead) if(!m_hiddenUntilBossDead)
{ {
m_starSinRotate=(m_starSinRotate+(16*_frames))&4095; m_starSinRotate=(m_starSinRotate+(16*_frames))&4095;
@ -231,11 +254,11 @@ void CQuestItemPickup::thinkPickup(int _frames)
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
Function: Function:
Purpose: LOTS to optimise here.. (pkg) Purpose:
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
static const int s_questStarFrames[8]={FRM__QUESTITEMSTAR1,FRM__QUESTITEMSTAR2,FRM__QUESTITEMSTAR3,FRM__QUESTITEMSTAR4}; static const int s_questStarFrames[8]={FRM__QUESTITEMSTAR1,FRM__QUESTITEMSTAR2,FRM__QUESTITEMSTAR3,FRM__QUESTITEMSTAR2};
void CQuestItemPickup::renderPickup(DVECTOR *_pos) void CQuestItemPickup::renderPickup(DVECTOR *_pos)
{ {
if(!m_hiddenUntilBossDead) if(!m_hiddenUntilBossDead)
@ -251,44 +274,45 @@ void CQuestItemPickup::renderPickup(DVECTOR *_pos)
sprites=CGameScene::getSpriteBank(); sprites=CGameScene::getSpriteBank();
// Quest item graphic // Quest item graphic
if(!m_collected)
{
fh=sprites->getFrameHeader(m_gfxFrame); fh=sprites->getFrameHeader(m_gfxFrame);
x=_pos->vx-(fh->W/2); x=_pos->vx-(fh->W/2);
y=_pos->vy-(fh->H/2); y=_pos->vy-(fh->H/2);
sprites->printFT4(fh,x,y,0,0,OTPOS__PICKUP_POS); sprites->printFT4(fh,x,y,0,0,OTPOS__PICKUP_POS);
}
// Stars // Stars
angle=m_starSinRotate; angle=m_starSinRotate;
radius=((msin(m_starSinRadius)*20)>>12)+35; radius=((msin(m_starSinRadius)*20)>>12)+40+(m_collectedFrameCount*2);
r=((msin(m_starSinR)*64)>>12)+128; r=((msin(m_starSinR)*64)>>12)+128;
g=((msin(m_starSinG)*64)>>12)+128; g=((msin(m_starSinG)*64)>>12)+128;
b=((msin(m_starSinB)*64)>>12)+128; b=((msin(m_starSinB)*64)>>12)+128;
fh=sprites->getFrameHeader(s_questStarFrames[(m_starFrame>>2)&3]); fh=sprites->getFrameHeader(s_questStarFrames[(m_starFrame>>3)&3]);
for(i=0;i<4;i++) for(i=0;i<4;i++)
{ {
POLY_FT4 *ft4; POLY_FT4 *ft4;
angle=(angle+1024)&4095; x=_pos->vx+((msin(angle)*radius)>>12);
x=_pos->vx+((msin(angle)*radius)>>12)-(fh->W/2); y=_pos->vy+((mcos(angle)*radius)>>12);
y=_pos->vy+((mcos(angle)*radius)>>12)-(fh->H/2);
ft4=sprites->printFT4(fh,x,y,0,0,0); ft4=sprites->printFT4(fh,x,y,0,0,0);
setRGB0(ft4,r,g,b); setRGB0(ft4,r,g,b);
setSemiTrans(ft4,true); angle=(angle+1024)&4095;
} }
angle=m_starSinRotate+512; angle=(m_starSinRotate+512)&4095;
radius=((msin((m_starSinRadius+2048)&4095)*20)>>12)+35; radius=((msin((m_starSinRadius+2048)&4095)*20)>>12)+40+(m_collectedFrameCount*2);
r=((msin((m_starSinR+2048)&4095)*64)>>12)+128; r=((msin((m_starSinR+2048)&4095)*64)>>12)+128;
g=((msin((m_starSinG+2048)&4095)*64)>>12)+128; g=((msin((m_starSinG+2048)&4095)*64)>>12)+128;
b=((msin((m_starSinB+2048)&4095)*64)>>12)+128; b=((msin((m_starSinB+2048)&4095)*64)>>12)+128;
fh=sprites->getFrameHeader(s_questStarFrames[((m_starFrame>>2)+2)&3]); fh=sprites->getFrameHeader(s_questStarFrames[((m_starFrame>>3)+2)&3]);
for(i=0;i<4;i++) for(i=0;i<4;i++)
{ {
POLY_FT4 *ft4; POLY_FT4 *ft4;
angle=(angle+1024)&4095; x=_pos->vx+((msin(angle)*radius)>>12);
x=_pos->vx+((msin(angle)*radius)>>12)-(fh->W/2); y=_pos->vy+((mcos(angle)*radius)>>12);
y=_pos->vy+((mcos(angle)*radius)>>12)-(fh->H/2);
ft4=sprites->printFT4(fh,x,y,0,0,0); ft4=sprites->printFT4(fh,x,y,0,0,0);
setRGB0(ft4,r,g,b); setRGB0(ft4,r,g,b);
setSemiTrans(ft4,true); angle=(angle+1024)&4095;
} }
} }
} }

View File

@ -56,6 +56,8 @@ private:
virtual CSoundMediator::SFXID sfxToPlayWhenCollected(){return CSoundMediator::SFX_ITEM__LEVEL_ITEM;} virtual CSoundMediator::SFXID sfxToPlayWhenCollected(){return CSoundMediator::SFX_ITEM__LEVEL_ITEM;}
int m_hiddenUntilBossDead; int m_hiddenUntilBossDead;
int m_collected,m_collectedFrameCount;
int m_starSinRotate; int m_starSinRotate;
int m_starSinRadius; int m_starSinRadius;
int m_starFrame; int m_starFrame;