This commit is contained in:
Paul 2001-04-08 18:57:16 +00:00
parent dc3dc29e5a
commit bef68f6b0e
7 changed files with 191 additions and 79 deletions

View File

@ -25,6 +25,10 @@
#include "utils\mathtab.h" #include "utils\mathtab.h"
#endif #endif
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
/* Std Lib /* Std Lib
------- */ ------- */
@ -90,6 +94,7 @@ DVECTOR CJellyLauncherAmmoPickup::getSizeForPlacement()
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CJellyLauncherAmmoPickup::collect(class CPlayer *_player) void CJellyLauncherAmmoPickup::collect(class CPlayer *_player)
{ {
_player->giveJellyAmmo();
CBasePickup::collect(_player); CBasePickup::collect(_player);
} }

View File

@ -246,7 +246,7 @@ void CPlayer::init()
s_playerModes[i]->initialise(this); s_playerModes[i]->initialise(this);
} }
m_currentPlayerModeClass=NULL; m_currentPlayerModeClass=NULL;
setMode(PLAYER_MODE_BASICUNARMED); //PKG setMode(PLAYER_MODE_FULLUNARMED); //PKG
m_animNo=0; m_animNo=0;
m_animFrame=0; m_animFrame=0;
@ -693,6 +693,7 @@ void CPlayer::respawn()
m_squeakyBootsTimer=0; m_squeakyBootsTimer=0;
m_invinvibilityRingTimer=0; m_invinvibilityRingTimer=0;
m_bubbleAmmo=0; m_bubbleAmmo=0;
m_jellyAmmo=0;
clearPlatform(); clearPlatform();
} }

View File

@ -253,12 +253,18 @@ public:
void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;} void giveBubbleAmmo() {m_bubbleAmmo+=10;if(m_bubbleAmmo>99)m_bubbleAmmo=99;}
void useOneBubble() {m_bubbleAmmo--;} void useOneBubble() {m_bubbleAmmo--;}
int getBubbleAmmo() {return m_bubbleAmmo;} int getBubbleAmmo() {return m_bubbleAmmo;}
void giveJellyAmmo() {m_jellyAmmo+=6;if(m_jellyAmmo>99)m_jellyAmmo=99;}
void useOneJelly() {m_jellyAmmo--;}
int getJellyAmmo() {return m_jellyAmmo;}
private: private:
int m_glassesFlag; int m_glassesFlag;
int m_squeakyBootsTimer; int m_squeakyBootsTimer;
int m_invinvibilityRingTimer; int m_invinvibilityRingTimer;
int m_divingHelmet; int m_divingHelmet;
int m_bubbleAmmo; int m_bubbleAmmo;
int m_jellyAmmo;
// Platforms // Platforms
public: public:

View File

@ -21,6 +21,18 @@
#include "gfx\sprbank.h" #include "gfx\sprbank.h"
#endif #endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
#ifndef __GFX_FONT_H__
#include "gfx\font.h"
#endif
/* Std Lib /* Std Lib
------- */ ------- */
@ -61,8 +73,8 @@
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayerModeJellyLauncher::enter() void CPlayerModeJellyLauncher::enter()
{ {
m_netting=false; m_firingState=FIRING_STATE__NONE;
m_netState=NET_STATE__EMPTY; m_player->giveJellyAmmo();
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -71,50 +83,88 @@ void CPlayerModeJellyLauncher::enter()
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
//int netstate; DVECTOR jellyLaunchPos={20,-40};
void CPlayerModeJellyLauncher::think() void CPlayerModeJellyLauncher::think()
{ {
// If we're netting 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_netting)
{
setAnimNo(m_savedAnimNo);
setAnimFrame(m_savedAnimFrame);
}
CPlayerModeBase::think(); CPlayerModeBase::think();
// Start to net? // Start to fire?
if(!m_netting&&getPadInputDown()&PI_ACTION&&canSwingNetFromThisState()) switch(m_firingState)
{ {
m_netFrame=0; case FIRING_STATE__NONE:
m_netting=true; if(getPadInputDown()&PI_ACTION&&m_player->getJellyAmmo()&&canFireFromThisState())
switch(m_netState) {
{ m_firingFrame=0;
case NET_STATE__EMPTY: m_firingTime=0;
m_netState=NET_STATE__FULL; m_firingState=FIRING_STATE__POWERINGUP;
break; }
case NET_STATE__FULL: break;
m_netState=NET_STATE__EMPTY; case FIRING_STATE__POWERINGUP:
break; if(getPadInputHeld()&PI_ACTION)
} {
} if(m_firingTime<TIMEOUT_FOR_BIG_SHOT)
{
m_firingTime++;
}
m_player->setAnimNo(ANIM_SPONGEBOB_FIRE);
}
else
{
m_firingState=FIRING_STATE__FIRING;
m_player->setAnimNo(ANIM_SPONGEBOB_FIRE);
}
break;
case FIRING_STATE__FIRING:
m_player->setAnimFrame(m_firingFrame++);
if(m_firingFrame>=m_player->getAnimFrameCount())
{
int playerFacing;
DVECTOR launchPos;
// Netting? playerFacing=m_player->getFacing();
if(m_netting) launchPos=getPlayerPos();
{ launchPos.vx+=playerFacing*jellyLaunchPos.vx;
//!!! m_player->setAnimNo(ANIM_SPONGEBOB_KARATE); launchPos.vy+=jellyLaunchPos.vy;
m_player->setAnimNo(ANIM_SPONGEBOB_FIRE); if(m_firingTime==TIMEOUT_FOR_BIG_SHOT&&m_player->getJellyAmmo()>=AMMO_AMOUNT_FOR_BIG_SHOT)
m_player->setAnimFrame(m_netFrame); {
m_netFrame++; // Powered up, big shot
if(m_netFrame>=m_player->getAnimFrameCount()) int fireHeading;
{ CPlayerProjectile *projectile;
m_player->setAnimNo(m_savedAnimNo); int i;
m_player->setAnimFrame(m_savedAnimFrame);
m_netting=false; fireHeading=1024+(1024*playerFacing)-512;
} for(i=0;i<3;i++)
{
projectile=new("JellyProjectile") CPlayerProjectile;
projectile->init(launchPos,
fireHeading,
CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE,
CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE,
5*60);
fireHeading+=512;
m_player->useOneJelly();
}
}
else
{
// Normal, small shot
int fireHeading;
CPlayerProjectile *projectile;
fireHeading=1024+(1024*m_player->getFacing());
projectile=new("JellyProjectile") CPlayerProjectile;
projectile->init(launchPos,
fireHeading,
CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE,
CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE,
5*60);
m_player->useOneJelly();
}
setState(STATE_IDLE);
m_firingState=FIRING_STATE__NONE;
}
break;
} }
// netstate=m_netState;
} }
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
@ -127,17 +177,80 @@ void CPlayerModeJellyLauncher::renderModeUi()
{ {
SpriteBank *sb; SpriteBank *sb;
sFrameHdr *fh; sFrameHdr *fh;
FontBank *fb;
char buf[4];
sb=m_player->getSpriteBank(); sb=m_player->getSpriteBank();
fh=sb->getFrameHeader(FRM__NET); fh=sb->getFrameHeader(FRM__BLOWER);
if(m_netState==NET_STATE__FULL) switch(m_firingState)
{ {
// Net has a jellyfish inside case FIRING_STATE__NONE:
sb->printFT4Scaled(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT,256+128); case FIRING_STATE__FIRING:
sb->printFT4(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT);
break;
case FIRING_STATE__POWERINGUP:
{
int rotRange,scaleBase,scaleRange;
int xs,ys,rot;
rotRange=m_firingTime;
scaleBase=4096+(m_firingTime*10);
scaleRange=m_firingTime*2;
rot=(getRndRange(rotRange*2)-rotRange)&4095;
xs=scaleBase+getRndRange(scaleRange);
ys=scaleBase+getRndRange(scaleRange);
sb->printRotatedScaledSprite(fh,CPlayer::POWERUPUI_ICONX,CPlayer::POWERUPUI_ICONY,xs,ys,rot,CPlayer::POWERUPUI_OT);
}
break;
}
fb=m_player->getFontBank();
sprintf(buf,"x%d",m_player->getJellyAmmo());
fb->print(CPlayer::POWERUPUI_TEXTX,CPlayer::POWERUPUI_TEXTY-(fb->getCharHeight()/2),buf);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CPlayerModeJellyLauncher::setState(int _state)
{
int allowChange;
allowChange=true;
if(m_firingState!=FIRING_STATE__NONE)
{
switch(_state)
{
case STATE_FALL:
// Break out of firing state!
m_firingState=FIRING_STATE__NONE;
break;
case STATE_IDLE:
case STATE_IDLETEETER:
case STATE_JUMP:
case STATE_RUN:
case STATE_FALLFAR:
case STATE_BUTTBOUNCE:
case STATE_BUTTFALL:
case STATE_BUTTLAND:
case STATE_DUCK:
case STATE_SOAKUP:
case STATE_GETUP:
allowChange=false;
break;
}
}
if(allowChange)
{
return CPlayerModeBase::setState(_state);
} }
else else
{ {
sb->printFT4(fh,CPlayer::POWERUPUI_ICONX-(fh->W/2),CPlayer::POWERUPUI_ICONY-(fh->H/2),0,0,CPlayer::POWERUPUI_OT); return false;
} }
} }
@ -147,25 +260,7 @@ void CPlayerModeJellyLauncher::renderModeUi()
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayerModeJellyLauncher::setAnimNo(int _animNo) int CPlayerModeJellyLauncher::canFireFromThisState()
{
CPlayerModeBase::setAnimNo(_animNo);
m_savedAnimNo=_animNo;
}
void CPlayerModeJellyLauncher::setAnimFrame(int _animFrame)
{
CPlayerModeBase::setAnimFrame(_animFrame);
m_savedAnimFrame=_animFrame;
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
int CPlayerModeJellyLauncher::canSwingNetFromThisState()
{ {
int ret=false; int ret=false;
@ -173,12 +268,12 @@ int CPlayerModeJellyLauncher::canSwingNetFromThisState()
{ {
case STATE_IDLE: case STATE_IDLE:
case STATE_IDLETEETER: case STATE_IDLETEETER:
case STATE_JUMP:
case STATE_RUN:
case STATE_FALL:
ret=true; ret=true;
break; break;
case STATE_JUMP:
case STATE_RUN:
case STATE_FALL:
case STATE_FALLFAR: case STATE_FALLFAR:
case STATE_BUTTBOUNCE: case STATE_BUTTBOUNCE:
case STATE_BUTTFALL: case STATE_BUTTFALL:

View File

@ -41,22 +41,27 @@ public:
virtual void think(); virtual void think();
virtual void renderModeUi(); virtual void renderModeUi();
virtual void setAnimNo(int _animNo); virtual int setState(int _state);
virtual void setAnimFrame(int _animFrame);
private: private:
enum
{
TIMEOUT_FOR_BIG_SHOT=60*4,
AMMO_AMOUNT_FOR_BIG_SHOT=3,
};
typedef enum typedef enum
{ {
NET_STATE__EMPTY, FIRING_STATE__NONE,
NET_STATE__FULL, FIRING_STATE__POWERINGUP,
} NetState; FIRING_STATE__FIRING,
}FIRING_STATE;
int canSwingNetFromThisState(); int canFireFromThisState();
int m_savedAnimNo,m_savedAnimFrame; int m_firingFrame;
int m_netFrame; FIRING_STATE m_firingState;
int m_netting; int m_firingTime;
NetState m_netState;
}; };

View File

@ -122,7 +122,7 @@ public:
virtual const struct PlayerMetrics *getPlayerMetrics(); virtual const struct PlayerMetrics *getPlayerMetrics();
int setState(int _state); virtual int setState(int _state);
int getState() {return m_currentState;} int getState() {return m_currentState;}
// virtual void setMode(class CPlayer *_player,int _mode); // virtual void setMode(class CPlayer *_player,int _mode);
int getFacing(); int getFacing();

View File

@ -56,7 +56,7 @@ class CPlayerStateWalk : public CPlayerStateRun
{ {
protected: protected:
virtual int getStartFrame() {return -1;} virtual int getStartFrame() {return -1;}
virtual int getLoopFrame() {return ANIM_SPONGEBOB_WALK;} virtual int getLoopFrame() {return ANIM_SPONGEBOB_RUN;} //{return ANIM_SPONGEBOB_WALK;}
virtual int getEndFrame() {return -1;} virtual int getEndFrame() {return -1;}
}; };