2001-03-25 22:49:18 +02:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
pmchop.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "player\pmchop.h"
|
|
|
|
|
2001-06-27 21:50:35 +02:00
|
|
|
#ifndef __GFX_SPRBANK_H__
|
|
|
|
#include "gfx\sprbank.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __GAME_GAME_H__
|
|
|
|
#include "game\game.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-25 22:49:18 +02:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2001-03-27 22:29:02 +02:00
|
|
|
#ifndef __ANIM_SPONGEBOB_HEADER__
|
|
|
|
#include <ACTOR_SPONGEBOB_ANIM.h>
|
|
|
|
#endif
|
|
|
|
|
2001-06-27 21:50:35 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 22:29:02 +02:00
|
|
|
|
2001-03-25 22:49:18 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-03-27 22:29:02 +02:00
|
|
|
void CPlayerModeChop::enter()
|
|
|
|
{
|
2001-05-13 21:28:48 +02:00
|
|
|
CPlayerModeBase::enter();
|
2001-03-27 22:29:02 +02:00
|
|
|
m_chopping=false;
|
2001-06-27 21:50:35 +02:00
|
|
|
m_timer=0;
|
2001-03-27 22:29:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-05-29 16:05:15 +02:00
|
|
|
int chopcsx=-25;
|
2001-05-01 22:23:32 +02:00
|
|
|
int chopcsy=-30;
|
|
|
|
int chopcsw=80;
|
|
|
|
int chopcsh=60;
|
2001-03-27 22:29:02 +02:00
|
|
|
void CPlayerModeChop::think()
|
|
|
|
{
|
|
|
|
// If we're chopping then restore the 'real' anim number/frame before
|
|
|
|
// doing the think so that the rest of the code doesn't know what
|
|
|
|
// is going on ;)
|
|
|
|
if(m_chopping)
|
|
|
|
{
|
|
|
|
setAnimNo(m_savedAnimNo);
|
|
|
|
setAnimFrame(m_savedAnimFrame);
|
|
|
|
}
|
|
|
|
CPlayerModeBase::think();
|
|
|
|
|
|
|
|
// Start to chop?
|
2001-05-10 00:12:00 +02:00
|
|
|
if(!m_chopping&&getPadInputDown()&PI_FIRE&&canAttackFromThisState())
|
2001-03-27 22:29:02 +02:00
|
|
|
{
|
|
|
|
m_chopFrame=0;
|
2001-05-01 22:23:32 +02:00
|
|
|
getPlayerCollisionSize(&m_savedCSX,&m_savedCSY,&m_savedCSW,&m_savedCSH);
|
2001-03-27 22:29:02 +02:00
|
|
|
m_chopping=true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Chopping?
|
|
|
|
if(m_chopping)
|
|
|
|
{
|
2001-05-29 16:05:15 +02:00
|
|
|
int facing;
|
|
|
|
facing=getFacing();
|
2001-06-25 16:37:59 +02:00
|
|
|
if(m_chopFrame==CHOP_ATTACK_START_FRAME)
|
|
|
|
{
|
|
|
|
m_chopping=false; // Oops..
|
|
|
|
setPlayerCollisionSize(chopcsx*facing,chopcsy,chopcsw,chopcsh);
|
|
|
|
m_chopping=true; // Oops..
|
|
|
|
}
|
|
|
|
else if(m_chopFrame==CHOP_ATTACK_END_FRAME+1)
|
|
|
|
{
|
|
|
|
m_chopping=false; // Oops..
|
|
|
|
setPlayerCollisionSize(m_savedCSX,m_savedCSY,m_savedCSW,m_savedCSH);
|
|
|
|
m_chopping=true; // Oops..
|
|
|
|
}
|
2001-05-29 16:05:15 +02:00
|
|
|
|
2001-04-08 18:20:09 +02:00
|
|
|
m_player->setAnimNo(ANIM_SPONGEBOB_KARATE);
|
2001-03-27 22:29:02 +02:00
|
|
|
m_player->setAnimFrame(m_chopFrame);
|
|
|
|
m_chopFrame++;
|
|
|
|
if(m_chopFrame>=m_player->getAnimFrameCount())
|
|
|
|
{
|
|
|
|
m_player->setAnimNo(m_savedAnimNo);
|
|
|
|
m_player->setAnimFrame(m_savedAnimFrame);
|
|
|
|
m_chopping=false;
|
2001-05-01 22:23:32 +02:00
|
|
|
setPlayerCollisionSize(m_savedCSX,m_savedCSY,m_savedCSW,m_savedCSH);
|
2001-03-27 22:29:02 +02:00
|
|
|
}
|
|
|
|
}
|
2001-06-27 21:50:35 +02:00
|
|
|
|
|
|
|
if(++m_timer>CHOP_TIMEOUT)
|
|
|
|
{
|
|
|
|
m_player->setMode(PLAYER_MODE_BASICUNARMED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerModeChop::renderModeUi()
|
|
|
|
{
|
|
|
|
if(m_timer<CHOP_TIMEOUT-CHOP_FLASH_TIME||m_timer&2)
|
|
|
|
{
|
|
|
|
SpriteBank *sb;
|
|
|
|
sFrameHdr *fh;
|
|
|
|
|
|
|
|
sb=CGameScene::getSpriteBank();
|
|
|
|
fh=sb->getFrameHeader(FRM__GLOVE);
|
|
|
|
|
|
|
|
sb->printFT4(fh,CPlayer::POWERUPUI_ICONX,CPlayer::POWERUPUI_ICONY,0,0,CPlayer::POWERUPUI_OT);
|
|
|
|
}
|
2001-03-27 22:29:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerModeChop::setAnimNo(int _animNo)
|
|
|
|
{
|
|
|
|
CPlayerModeBase::setAnimNo(_animNo);
|
|
|
|
m_savedAnimNo=_animNo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerModeChop::setAnimFrame(int _animFrame)
|
|
|
|
{
|
|
|
|
CPlayerModeBase::setAnimFrame(_animFrame);
|
|
|
|
m_savedAnimFrame=_animFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-04-12 20:48:33 +02:00
|
|
|
ATTACK_STATE CPlayerModeChop::getAttackState()
|
2001-03-27 22:29:02 +02:00
|
|
|
{
|
2001-06-25 16:37:59 +02:00
|
|
|
if(m_chopping&&m_chopFrame>=CHOP_ATTACK_START_FRAME&&m_chopFrame<=CHOP_ATTACK_END_FRAME)
|
2001-04-12 20:48:33 +02:00
|
|
|
{
|
|
|
|
return ATTACK_STATE__KARATE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return CPlayerModeBase::getAttackState();
|
|
|
|
}
|
2001-03-27 22:29:02 +02:00
|
|
|
}
|
|
|
|
|
2001-05-01 22:23:32 +02:00
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CPlayerModeChop::setPlayerCollisionSize(int _x,int _y,int _w,int _h)
|
|
|
|
{
|
|
|
|
if(m_chopping)
|
|
|
|
{
|
|
|
|
m_savedCSX=_x;
|
|
|
|
m_savedCSY=_y;
|
|
|
|
m_savedCSW=_w;
|
|
|
|
m_savedCSY=_h;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CPlayerModeBase::setPlayerCollisionSize(_x,_y,_w,_h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-27 22:29:02 +02:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-04-12 20:48:33 +02:00
|
|
|
int CPlayerModeChop::canAttackFromThisState()
|
2001-03-27 22:29:02 +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;
|
|
|
|
|
2001-05-01 20:39:41 +02:00
|
|
|
case STATE_SPRINGUP:
|
2001-03-27 22:29:02 +02:00
|
|
|
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-27 22:29:02 +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-27 22:29:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2001-03-25 22:49:18 +02:00
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|