2001-03-30 19:21:04 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
pmbubble.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
2001-04-27 13:52:40 +02:00
|
|
|
Created:
|
2001-03-30 19:21:04 +02:00
|
|
|
Project: Spongebob
|
2001-04-27 13:52:40 +02:00
|
|
|
Purpose:
|
2001-03-30 19:21:04 +02:00
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "player\pmbubble.h"
|
2001-03-31 20:22:38 +02:00
|
|
|
|
2001-06-14 18:07:48 +02:00
|
|
|
#ifndef __PLATFORM_PLATFORM_H__
|
|
|
|
#include "platform\platform.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
|
|
|
|
2001-06-25 22:25:28 +02:00
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game/game.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// States
|
|
|
|
#ifndef __PLAYER__PSLOOK_H__
|
|
|
|
#include "player\pslook.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSJUMP_H__
|
|
|
|
#include "player\psjump.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSJMPBCK_H__
|
|
|
|
#include "player\psjmpbck.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSRUN_H__
|
|
|
|
#include "player\psrun.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSFALL_H__
|
|
|
|
#include "player\psfall.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSHITGND_H__
|
|
|
|
#include "player\pshitgnd.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSIDLE_H__
|
|
|
|
#include "player\psidle.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSBUTT_H__
|
|
|
|
#include "player\psbutt.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSDUCK_H__
|
|
|
|
#include "player\psduck.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER__PSSPRING_H__
|
|
|
|
#include "player\psspring.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PSCART_H__
|
|
|
|
#include "player\pscart.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PLAYER_PSFLOAT_H__
|
|
|
|
#include "player\psfloat.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-03 00:57:52 +02:00
|
|
|
#ifndef __PLAYER_PSDANCE_H__
|
|
|
|
#include "player\psdance.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-03 22:49:30 +02:00
|
|
|
#ifndef __PLAYER_PSSWAL_H__
|
|
|
|
#include "player\psswal.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
|
|
|
|
---- */
|
|
|
|
|
2001-06-25 22:25:28 +02:00
|
|
|
static CPlayerState *s_stateTable[]=
|
|
|
|
{
|
2001-07-12 21:55:16 +02:00
|
|
|
&s_stateWeaponIdle, // STATE_IDLE
|
2001-06-25 22:25:28 +02:00
|
|
|
&s_stateTeeterIdle, // STATE_IDLETEETER
|
|
|
|
&s_stateJump, // STATE_JUMP
|
|
|
|
&s_stateSpring, // STATE_SPRINGUP
|
|
|
|
&s_stateRun, // STATE_RUN
|
|
|
|
&s_stateFall, // STATE_FALL
|
|
|
|
&s_stateFallFar, // STATE_FALLFAR
|
|
|
|
&s_stateHitGround, // STATE_HITGROUND
|
|
|
|
&s_stateButtBounce, // STATE_BUTTBOUNCE
|
|
|
|
&s_stateButtBounceFall, // STATE_BUTTFALL
|
|
|
|
&s_stateButtBounceLand, // STATE_BUTTLAND
|
|
|
|
&s_stateButtBounceUp, // STATE_BUTTBOUNCEUP
|
|
|
|
&s_stateSoakUp, // STATE_SOAKUP
|
|
|
|
&s_stateGetUp, // STATE_GETUP
|
|
|
|
&s_stateLookDown, // STATE_LOOKDOWN
|
|
|
|
&s_stateLookDownRelax, // STATE_LOOKDOWNRELAX
|
|
|
|
&s_stateLookUp, // STATE_LOOKUP
|
|
|
|
&s_stateLookUpRelax, // STATE_LOOKUPRELAX
|
|
|
|
&s_stateJumpBack, // STATE_JUMPBACK
|
|
|
|
&s_stateCart, // STATE_CART
|
|
|
|
&s_stateFloat, // STATE_FLOAT
|
2001-07-03 00:57:52 +02:00
|
|
|
&s_stateDance, // STATE_CELEBRATE
|
2001-07-03 22:49:30 +02:00
|
|
|
&s_stateSwallow, // STATE_SWALLOW
|
2001-06-25 22:25:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-03-30 19:21:04 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerModeBubbleMixture::enter()
|
|
|
|
{
|
2001-05-13 21:28:48 +02:00
|
|
|
CPlayerModeBase::enter();
|
2001-03-30 21:27:26 +02:00
|
|
|
m_blowing=false;
|
|
|
|
m_bubbleDelay=0;
|
2001-03-30 19:21:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-21 18:34:01 +02:00
|
|
|
DVECTOR buboff={-80,-10};
|
2001-03-31 04:05:24 +02:00
|
|
|
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-05-10 00:12:00 +02:00
|
|
|
if(!m_blowing&&getPadInputDown()&PI_FIRE&&canBlowBubbleFromThisState()&&m_player->getBubbleAmmo())
|
2001-03-30 21:27:26 +02:00
|
|
|
{
|
|
|
|
// Spawn the bubbly platform thingy..!
|
2001-06-14 18:07:48 +02:00
|
|
|
CNpcPlatform *bubble;
|
2001-03-31 04:05:24 +02:00
|
|
|
DVECTOR pos;
|
2001-06-14 18:07:48 +02:00
|
|
|
bubble = CNpcPlatform::Create( 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;
|
2001-06-28 15:56:05 +02:00
|
|
|
bubble->setGraphic( (u8) 0 );
|
2001-03-31 04:05:24 +02:00
|
|
|
bubble->init(pos,4);
|
2001-05-21 18:19:58 +02:00
|
|
|
bubble->postInit();
|
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;
|
|
|
|
|
2001-05-25 20:43:47 +02:00
|
|
|
sb=CGameScene::getSpriteBank();
|
2001-07-16 22:55:33 +02:00
|
|
|
fh=sb->getFrameHeader(FRM__SMALL_BUBBLEWAND);
|
2001-05-02 22:27:49 +02:00
|
|
|
sb->printFT4(fh,CPlayer::POWERUPUI_ICONX,CPlayer::POWERUPUI_ICONY,0,0,CPlayer::POWERUPUI_OT);
|
2001-03-31 20:22:38 +02:00
|
|
|
|
|
|
|
fb=m_player->getFontBank();
|
|
|
|
sprintf(buf,"x%d",m_player->getBubbleAmmo());
|
2001-05-02 22:27:49 +02:00
|
|
|
fb->print(CPlayer::POWERUPUI_TEXTX,CPlayer::POWERUPUI_TEXTY,buf);
|
2001-03-31 20:22:38 +02:00
|
|
|
}
|
|
|
|
|
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:
|
2001-07-21 21:19:34 +02:00
|
|
|
case STATE_SPRINGUP:
|
2001-03-30 19:21:04 +02:00
|
|
|
ret=true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_FALLFAR:
|
|
|
|
case STATE_BUTTBOUNCE:
|
|
|
|
case STATE_BUTTFALL:
|
|
|
|
case STATE_BUTTLAND:
|
2001-05-11 22:56:43 +02:00
|
|
|
case STATE_BUTTBOUNCEUP:
|
2001-03-30 19:21:04 +02:00
|
|
|
case STATE_SOAKUP:
|
|
|
|
case STATE_GETUP:
|
2001-05-29 17:54:26 +02:00
|
|
|
case STATE_LOOKDOWN:
|
|
|
|
case STATE_LOOKDOWNRELAX:
|
2001-06-19 17:23:50 +02:00
|
|
|
case STATE_LOOKUP:
|
|
|
|
case STATE_LOOKUPRELAX:
|
2001-05-11 21:49:41 +02:00
|
|
|
case STATE_JUMPBACK:
|
2001-03-30 19:21:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-06-25 22:25:28 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
CPlayerState **CPlayerModeBubbleMixture::getStateTable()
|
|
|
|
{
|
|
|
|
return s_stateTable;
|
|
|
|
}
|
|
|
|
|
2001-03-30 19:21:04 +02:00
|
|
|
/*===========================================================================
|
2001-04-27 13:52:40 +02:00
|
|
|
end */
|