2001-02-20 23:53:35 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
pickup.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2001 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#ifndef __GFX_SPRBANK_H__
|
|
|
|
#include "gfx\sprbank.h" // Damnit.. include order! :( (pkg)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pickups\pickup.h"
|
|
|
|
|
|
|
|
#ifndef __LEVEL_LEVEL_H__
|
|
|
|
#include "level\level.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For the factory..
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PHEALTH_H__
|
|
|
|
#include "pickups\phealth.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PLIFE_H__
|
|
|
|
#include "pickups\plife.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PSPATULA_H__
|
|
|
|
#include "pickups\pspatula.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PJLAMMO_H__
|
|
|
|
#include "pickups\pjlammo.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PBUBMIX_H__
|
|
|
|
#include "pickups\pbubmix.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-30 19:47:00 +02:00
|
|
|
#ifndef __PICKUPS_PBLOWER_H__
|
|
|
|
#include "pickups\pblower.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PGLASSES_H__
|
|
|
|
#include "pickups\pglasses.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PSHOES_H__
|
|
|
|
#include "pickups\pshoes.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
#ifndef __PICKUPS_PBALLOON_H__
|
|
|
|
#include "pickups\pballoon.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __PICKUPS_PHELMET_H__
|
|
|
|
#include "pickups\phelmet.h"
|
|
|
|
#endif
|
|
|
|
|
2001-03-31 04:05:24 +02:00
|
|
|
#ifndef __PICKUPS_PNET_H__
|
|
|
|
#include "pickups\pnet.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
#ifndef __PICKUPS_PQUEST_H__
|
|
|
|
#include "pickups\pquest.h"
|
|
|
|
#endif
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
2001-04-20 16:53:35 +02:00
|
|
|
#ifndef __SPR_SPRITES_H__
|
|
|
|
#include <sprites.h>
|
2001-02-20 23:53:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::init()
|
|
|
|
{
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::init();
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
m_spriteBank=new ("pickup sprite") SpriteBank();
|
2001-04-20 16:53:35 +02:00
|
|
|
m_spriteBank->load(SPRITES_SPRITES_SPR);
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::shutdown()
|
|
|
|
{
|
|
|
|
m_spriteBank->dump(); delete m_spriteBank;
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::shutdown();
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-21 23:33:17 +01:00
|
|
|
#include "pad\pads.h"
|
2001-02-20 23:53:35 +01:00
|
|
|
void CBasePickup::think(int _frames)
|
|
|
|
{
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::think(_frames);
|
2001-02-21 23:33:17 +01:00
|
|
|
thinkPickup(_frames);
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::render()
|
|
|
|
{
|
2001-02-21 23:33:17 +01:00
|
|
|
DVECTOR ofs,pos;
|
|
|
|
int visibilityRadius;
|
|
|
|
|
2001-02-26 21:42:25 +01:00
|
|
|
CPickupThing::render();
|
2001-02-21 23:33:17 +01:00
|
|
|
|
|
|
|
ofs=CLevel::getCameraPos();
|
|
|
|
pos.vx=Pos.vx-ofs.vx;
|
|
|
|
pos.vy=Pos.vy-ofs.vy;
|
|
|
|
visibilityRadius=getVisibilityRadius();
|
|
|
|
if(pos.vx>0-visibilityRadius&&pos.vx<512+visibilityRadius&&
|
|
|
|
pos.vy>0-visibilityRadius&&pos.vy<256+visibilityRadius)
|
|
|
|
{
|
|
|
|
renderPickup(&pos);
|
|
|
|
}
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
2001-02-26 21:42:25 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::collidedWith(CThing *_thisThing)
|
|
|
|
{
|
|
|
|
switch(_thisThing->getThingType())
|
|
|
|
{
|
|
|
|
case TYPE_PLAYER:
|
|
|
|
collect((CPlayer*)_thisThing);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::setPos(const DVECTOR *_pos)
|
|
|
|
{
|
|
|
|
Pos=*_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBasePickup::collect(class CPlayer *_player)
|
|
|
|
{
|
|
|
|
shutdown();
|
|
|
|
delete this;
|
|
|
|
}
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-21 23:33:17 +01:00
|
|
|
void CBaseRespawningPickup::init()
|
2001-02-20 23:53:35 +01:00
|
|
|
{
|
2001-02-21 23:33:17 +01:00
|
|
|
CBasePickup::init();
|
|
|
|
m_respawnTime=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
2001-02-27 17:59:50 +01:00
|
|
|
int respawnFlashFrames=50;
|
2001-02-21 23:33:17 +01:00
|
|
|
void CBaseRespawningPickup::think(int _frames)
|
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
if(m_respawnTime<=respawnFlashFrames)
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
CBasePickup::think(_frames);
|
|
|
|
}
|
2001-02-27 17:59:50 +01:00
|
|
|
|
|
|
|
if(m_respawnTime)
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
m_respawnTime-=_frames;
|
|
|
|
if(m_respawnTime<0)
|
|
|
|
{
|
|
|
|
m_respawnTime=0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseRespawningPickup::render()
|
|
|
|
{
|
|
|
|
if(m_respawnTime==0||
|
2001-02-27 17:59:50 +01:00
|
|
|
m_respawnTime<respawnFlashFrames&&!(m_respawnTime&4))
|
2001-02-21 23:33:17 +01:00
|
|
|
{
|
|
|
|
CBasePickup::render();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
void CBaseRespawningPickup::collect(class CPlayer *_player)
|
|
|
|
{
|
|
|
|
m_respawnTime=getRespawnTime();
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
2001-02-21 18:13:37 +01:00
|
|
|
Purpose: This is basically a factory method for making pickups :)
|
2001-02-20 23:53:35 +01:00
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
CBasePickup *createPickup(const PICKUP_TYPE _type,const DVECTOR *_pos)
|
|
|
|
{
|
|
|
|
CBasePickup *pickup;
|
2001-04-02 23:37:20 +02:00
|
|
|
DVECTOR pickupPos;
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
switch(_type)
|
|
|
|
{
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__BIG_HEALTH:
|
|
|
|
pickup=new ("LargeHealthPickup") CLargeHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__MEDIUM_HEALTH:
|
|
|
|
pickup=new ("MediumHealthPickup") CMediumHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
2001-02-27 17:59:50 +01:00
|
|
|
case PICKUP__SMALL_HEALTH:
|
|
|
|
pickup=new ("SmallHealthPickup") CSmallHealthPickup();
|
2001-02-20 23:53:35 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__LIFE:
|
|
|
|
pickup=new ("LifePickup") CLifePickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__SPATULA:
|
|
|
|
pickup=new ("SpatulaPickup") CSpatulaPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
case PICKUP__JELLY_LAUNCHER_AMMO:
|
|
|
|
pickup=new ("JellyLauncherAmmoPickup") CJellyLauncherAmmoPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__BUBBLE_MIXTURE:
|
|
|
|
pickup=new ("BubbleAmmoPickup") CBubbleMixturePickup();
|
|
|
|
break;
|
|
|
|
|
2001-03-31 04:05:24 +02:00
|
|
|
case PICKUP__BUBBLE_WAND:
|
|
|
|
pickup=new ("BubbleWandPickup") CBubbleWandPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__NET:
|
|
|
|
pickup=new ("NetPickup") CNetPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
case PICKUP__GLASSES:
|
|
|
|
pickup=new ("GlassesPickup") CGlassesPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__SQUEAKY_SHOES:
|
|
|
|
pickup=new ("ShoesPickup") CShoesPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 23:33:17 +01:00
|
|
|
case PICKUP__BALLOON:
|
|
|
|
pickup=new ("BalloonPickup") CBalloonPickup();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PICKUP__HELMET:
|
|
|
|
pickup=new ("HelmetPickup") CHelmetPickup();
|
|
|
|
break;
|
|
|
|
|
2001-03-30 19:47:00 +02:00
|
|
|
case PICKUP__CORAL_BLOWER:
|
|
|
|
pickup=new ("CoralBlowerPickup") CCoralBlowerPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-21 18:13:37 +01:00
|
|
|
case PICKUP__QUEST_ITEM__TEST:
|
|
|
|
pickup=new ("QuestItemPickup") CTestQuestItemPickup();
|
|
|
|
break;
|
|
|
|
|
2001-04-19 21:18:22 +02:00
|
|
|
case PICKUP__BALLOON_AND_SPATULA:
|
|
|
|
pickup=new ("BalloonAndSpatulaPickup") CBalloonAndSpatulaPickup();
|
|
|
|
break;
|
|
|
|
|
2001-02-20 23:53:35 +01:00
|
|
|
default:
|
|
|
|
ASSERT(!"UNKNOWN PICKUP TYPE");
|
2001-04-19 21:18:22 +02:00
|
|
|
return NULL;
|
2001-02-20 23:53:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pickup->init();
|
2001-04-02 23:37:20 +02:00
|
|
|
pickupPos=pickup->getSizeForPlacement();
|
|
|
|
pickupPos.vx=_pos->vx+(pickupPos.vx/2);
|
|
|
|
pickupPos.vy=_pos->vy+(pickupPos.vy/2)-16;
|
|
|
|
pickup->setPos(&pickupPos);
|
2001-02-20 23:53:35 +01:00
|
|
|
|
|
|
|
return pickup;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================
|
|
|
|
end */
|