SBSPSS/source/player/pmdead.cpp

189 lines
3.8 KiB
C++
Raw Normal View History

2001-03-25 23:09:06 +02:00
/*=========================================================================
pmdead.cpp
Author: PKG
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "player\pmdead.h"
2001-05-11 03:58:36 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-07-18 17:05:57 +02:00
#ifndef __GAME_GAMESLOT_H__
#include "game\gameslot.h"
#endif
2001-03-25 23:09:06 +02:00
/* Std Lib
------- */
/* Data
---- */
2001-04-05 18:26:17 +02:00
#ifndef __ANIM_SPONGEBOB_HEADER__
#include <ACTOR_SPONGEBOB_ANIM.h>
#endif
2001-03-25 23:09:06 +02:00
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeDead::enter()
{
2001-03-25 23:33:20 +02:00
m_deadTime=0;
2001-05-17 20:42:59 +02:00
switch(m_player->getDeathType())
{
default:
case DEATHTYPE__NORMAL:
case DEATHTYPE__DRYUP:
case DEATHTYPE__SQUASH:
2001-08-15 22:12:32 +02:00
m_deathAnim=ANIM_SPONGEBOB_DEATHBOUNCE;
m_deathMovementType=BOUNCE_OFF_SCREEN;
m_bounceVelocity.vx=BOUNCE_INITIALX*m_player->getFacing();
m_bounceVelocity.vy=BOUNCE_INITIALY;
m_player->setSBOTPosToFront();
2001-05-17 20:42:59 +02:00
break;
2001-06-04 16:41:56 +02:00
case DEATHTYPE__LIQUID:
2001-08-14 23:03:31 +02:00
m_deathAnim=ANIM_SPONGEBOB_DEATHTAR;
2001-08-15 22:12:32 +02:00
m_deathMovementType=STAY_STILL;
2001-06-04 16:41:56 +02:00
break;
2001-07-18 01:26:21 +02:00
case DEATHTYPE__FALL_TO_DEATH:
2001-07-30 17:08:29 +02:00
m_deathAnim=-1;
2001-08-15 22:12:32 +02:00
m_deathMovementType=FALL_TO_DEATH;
2001-07-18 01:26:21 +02:00
break;
}
2001-07-30 17:08:29 +02:00
if(m_deathAnim!=-1)
2001-07-18 01:26:21 +02:00
{
2001-07-30 17:08:29 +02:00
m_player->setAnimNo(m_deathAnim);
2001-05-17 20:42:59 +02:00
}
2001-07-24 17:25:54 +02:00
2001-07-26 17:22:34 +02:00
CSoundMediator::stopSpeech();
2001-07-24 17:25:54 +02:00
m_killed=false;
2001-08-17 17:04:17 +02:00
m_player->clearPlatform();
2001-03-25 23:09:06 +02:00
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CPlayerModeDead::think()
{
2001-03-25 23:33:20 +02:00
m_deadTime++;
2001-07-18 01:26:21 +02:00
if(m_player->getDeathType()!=DEATHTYPE__FALL_TO_DEATH)
2001-04-19 16:33:27 +02:00
{
2001-07-30 17:08:29 +02:00
int frameCount,frame;
if(m_deathAnim!=-1)
{
m_player->setAnimNo(m_deathAnim);
}
frameCount=m_player->getAnimFrameCount()-1;
if(m_deadTime<=frameCount)
{
frame=m_deadTime;
}
else
2001-07-18 01:26:21 +02:00
{
2001-07-30 17:08:29 +02:00
frame=frameCount;
2001-07-18 01:26:21 +02:00
}
2001-07-30 17:08:29 +02:00
m_player->setAnimFrame(frame);
2001-04-19 16:33:27 +02:00
}
2001-08-16 18:21:06 +02:00
if(m_player->getPos().vy<GameScene.GetLevel().getMapHeight16()+(4*16))
2001-08-14 20:36:21 +02:00
{
2001-08-15 22:12:32 +02:00
if(m_deathMovementType==FALL_TO_DEATH)
{
m_player->moveVertical(5);
}
else if(m_deathMovementType==BOUNCE_OFF_SCREEN)
{
DVECTOR pos=m_player->getPos();
pos.vx+=m_bounceVelocity.vx>>BOUNCE_VELOCITY_SHIFT;
pos.vy+=m_bounceVelocity.vy>>BOUNCE_VELOCITY_SHIFT;
if(pos.vy<0)pos.vy=0;
m_player->setPos(pos);
if(m_bounceVelocity.vy<BOUNCE_MAXY)
{
m_bounceVelocity.vy+=BOUNCE_MOVEY;
if(m_bounceVelocity.vy>BOUNCE_MAXY)
{
m_bounceVelocity.vy=BOUNCE_MAXY;
}
}
if(m_bounceVelocity.vx<0)
{
m_bounceVelocity.vx+=BOUNCE_MOVEX;
if(m_bounceVelocity.vx>0)
{
m_bounceVelocity.vx=0;
}
}
else if(m_bounceVelocity.vx>0)
{
m_bounceVelocity.vx-=BOUNCE_MOVEX;
if(m_bounceVelocity.vx<0)
{
m_bounceVelocity.vx=0;
}
}
}
2001-08-14 20:36:21 +02:00
}
2001-04-25 20:38:33 +02:00
2001-07-24 17:25:54 +02:00
if(!m_killed)
2001-03-25 23:09:06 +02:00
{
2001-07-30 17:08:29 +02:00
if((m_deadTime>DEATH_DELAY&&m_player->getPadInputDown()&(PI_JUMP|PI_FIRE))||
m_deadTime>DEATH_TIMEOUT)
{
2001-07-31 23:01:04 +02:00
if(GameScene.getLevelNumber()!=5)
{
// Take a life off..
CGameSlotManager::getSlotData()->m_lives--;
}
2001-07-18 17:05:57 +02:00
2001-07-30 17:08:29 +02:00
CGameScene::restartlevel();
m_killed=true;
}
2001-03-25 23:09:06 +02:00
}
}
/*===========================================================================
end */