SBSPSS/source/player/pmbubble.cpp

215 lines
4.8 KiB
C++
Raw Normal View History

2001-03-30 19:21:04 +02:00
/*=========================================================================
pmbubble.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "player\pmbubble.h"
2001-03-31 20:22:38 +02:00
#ifndef __ENEMY_NPLATFRM_H__
2001-03-31 00:43:35 +02:00
#include "enemy\nplatfrm.h"
2001-03-31 20:22:38 +02:00
#endif
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
2001-03-30 19:21:04 +02:00
/* Std Lib
------- */
/* Data
---- */
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
#endif
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2001-03-31 20:22:38 +02:00
#endif
2001-03-30 19:21:04 +02:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeBubbleMixture::enter()
{
2001-03-30 21:27:26 +02:00
CSoundMediator::playSfx(CSoundMediator::SFX_BUBBLE_WAND);
m_blowing=false;
m_bubbleDelay=0;
2001-03-31 04:05:24 +02:00
m_player->giveBubbleAmmo();
2001-03-30 19:21:04 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-31 04:05:24 +02:00
DVECTOR buboff={-40,-40};
int bubam;
2001-03-30 19:21:04 +02:00
void CPlayerModeBubbleMixture::think()
{
2001-03-30 21:27:26 +02:00
// If we're blowing then restore the 'real' anim number/frame before
2001-03-30 19:21:04 +02:00
// doing the think so that the rest of the code doesn't know what
// is going on ;)
2001-03-30 21:27:26 +02:00
if(m_blowing)
2001-03-30 19:21:04 +02:00
{
setAnimNo(m_savedAnimNo);
setAnimFrame(m_savedAnimFrame);
}
CPlayerModeBase::think();
2001-03-30 21:27:26 +02:00
if(m_bubbleDelay)
2001-03-30 19:21:04 +02:00
{
2001-03-30 21:27:26 +02:00
// Delay so that you can't blow all of your bubbles really quickly
m_bubbleDelay--;
2001-03-30 19:21:04 +02:00
}
2001-03-30 21:27:26 +02:00
else
{
// Start to blow?
2001-03-31 04:05:24 +02:00
if(!m_blowing&&getPadInputDown()&PI_ACTION&&canBlowBubbleFromThisState()&&m_player->getBubbleAmmo())
2001-03-30 21:27:26 +02:00
{
// Spawn the bubbly platform thingy..!
2001-03-31 04:05:24 +02:00
CNpcPlatform *bubble;
DVECTOR pos;
bubble=new ("bubble platform") CNpcPlatform;
2001-04-07 17:39:22 +02:00
bubble->setType( CNpcPlatform::NPC_PLAYER_BUBBLE_PLATFORM );
2001-03-31 04:05:24 +02:00
pos=m_player->getPos();
pos.vx+=buboff.vx*m_player->getFacing();
pos.vy+=buboff.vy;
bubble->init(pos,4);
2001-03-30 19:21:04 +02:00
2001-03-31 04:05:24 +02:00
// Start the blowing anim off
2001-03-30 21:27:26 +02:00
m_blowFrame=0;
m_blowing=true;
2001-03-31 00:43:35 +02:00
2001-03-31 04:05:24 +02:00
// One less bubble..
m_player->useOneBubble();
2001-03-30 21:27:26 +02:00
}
}
// Blowing?
if(m_blowing)
2001-03-30 19:21:04 +02:00
{
2001-04-09 18:52:12 +02:00
m_player->setAnimNo(ANIM_SPONGEBOB_BLOWBUBBLE);
2001-03-30 21:27:26 +02:00
m_player->setAnimFrame(m_blowFrame);
m_blowFrame++;
if(m_blowFrame>=m_player->getAnimFrameCount())
2001-03-30 19:21:04 +02:00
{
m_player->setAnimNo(m_savedAnimNo);
m_player->setAnimFrame(m_savedAnimFrame);
2001-03-30 21:27:26 +02:00
m_blowing=false;
m_bubbleDelay=BUBBLE_DELAY;
2001-03-30 19:21:04 +02:00
}
}
2001-03-31 04:05:24 +02:00
bubam=m_player->getBubbleAmmo();
2001-03-30 19:21:04 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeBubbleMixture::setAnimNo(int _animNo)
{
CPlayerModeBase::setAnimNo(_animNo);
m_savedAnimNo=_animNo;
}
void CPlayerModeBubbleMixture::setAnimFrame(int _animFrame)
{
CPlayerModeBase::setAnimFrame(_animFrame);
m_savedAnimFrame=_animFrame;
}
2001-03-31 20:22:38 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeBubbleMixture::renderModeUi()
{
SpriteBank *sb;
sFrameHdr *fh;
char buf[4];
FontBank *fb;
sb=m_player->getSpriteBank();
fh=sb->getFrameHeader(FRM__BUBBLEWAND);
sb->printFT4(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT);
fb=m_player->getFontBank();
sprintf(buf,"x%d",m_player->getBubbleAmmo());
fb->print(CPlayer::POWERUPUI_TEXTX,CPlayer::POWERUPUI_TEXTY-(fb->getCharHeight()/2),buf);
}
2001-03-30 19:21:04 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-30 21:27:26 +02:00
int CPlayerModeBubbleMixture::canBlowBubbleFromThisState()
2001-03-30 19:21:04 +02:00
{
int ret=false;
switch(getState())
{
case STATE_IDLE:
case STATE_IDLETEETER:
case STATE_JUMP:
case STATE_RUN:
case STATE_FALL:
ret=true;
break;
case STATE_FALLFAR:
case STATE_BUTTBOUNCE:
case STATE_BUTTFALL:
case STATE_BUTTLAND:
case STATE_DUCK:
case STATE_SOAKUP:
case STATE_GETUP:
break;
}
return ret;
}
/*===========================================================================
end */