SBSPSS/source/pickups/pglasses.cpp

165 lines
3.8 KiB
C++
Raw Normal View History

2001-06-13 18:59:29 +02:00
dsadsasdsad
2001-02-21 15:54:40 +01:00
/*=========================================================================
pglasses.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\pglasses.h"
2001-04-30 23:27:46 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-03-02 17:02:30 +01:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-04-19 22:46:43 +02:00
#ifndef __GFX_OTPOS_H__
#include "gfx\otpos.h"
#endif
2001-05-25 20:43:47 +02:00
#include "game/game.h"
2001-02-21 15:54:40 +01:00
/* Std Lib
------- */
/* Data
---- */
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2001-02-21 15:54:40 +01:00
#endif
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
/*----------------------------------------------------------------------
Function Prototypes
------------------- */
/*----------------------------------------------------------------------
Vars
---- */
2001-02-23 22:40:22 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CGlassesPickup::init()
{
2001-04-20 18:57:05 +02:00
sFrameHdr *fh;
2001-02-23 22:40:22 +01:00
CBasePickup::init();
m_glint=0;
2001-03-29 22:53:10 +02:00
m_glintRot=0;
2001-04-20 18:57:05 +02:00
2001-05-25 20:43:47 +02:00
fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__GLASSES);
2001-04-20 18:57:05 +02:00
setCollisionSize(fh->W,fh->H);
2001-04-30 23:27:46 +02:00
2001-05-11 23:53:37 +02:00
GameScene.getPlayer()->registerAddon(PLAYER_ADDON_GLASSES);
2001-02-23 22:40:22 +01:00
}
2001-04-02 23:37:20 +02:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
DVECTOR CGlassesPickup::getSizeForPlacement()
{
DVECTOR size;
sFrameHdr *fh;
2001-05-25 20:43:47 +02:00
fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__GLASSES);
2001-04-02 23:37:20 +02:00
size.vx=fh->W;
size.vy=fh->H;
return size;
}
2001-02-21 15:54:40 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-21 23:33:17 +01:00
void CGlassesPickup::collect(class CPlayer *_player)
2001-02-21 15:54:40 +01:00
{
2001-03-02 17:02:30 +01:00
_player->giveGlasses();
2001-02-21 23:33:17 +01:00
CBasePickup::collect(_player);
2001-02-21 15:54:40 +01:00
}
2001-02-23 22:40:22 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-03-29 22:53:10 +02:00
int glasses_glintframes=16;
int glasses_glintwait=400;
2001-02-23 22:40:22 +01:00
int glasses_glintspeed=1;
2001-03-29 22:53:10 +02:00
int glasses_glintRotSpeed=200;
2001-03-31 00:34:54 +02:00
DVECTOR glasses_gxy={2,2};
2001-03-29 22:53:10 +02:00
static const int glasses_glintFrames[]={FRM__GLINT1,FRM__GLINT2,FRM__GLINT3,FRM__GLINT4,FRM__GLINT4,FRM__GLINT3,FRM__GLINT2,FRM__GLINT1};
2001-02-23 22:40:22 +01:00
void CGlassesPickup::thinkPickup(int _frames)
{
2001-03-29 22:53:10 +02:00
m_glint+=_frames;
2001-02-23 22:40:22 +01:00
if(m_glint>glasses_glintframes+glasses_glintwait)m_glint=0;
2001-03-29 22:53:10 +02:00
m_glintRot+=_frames*glasses_glintRotSpeed;
m_glintRot&=4095;
2001-02-23 22:40:22 +01:00
}
2001-02-21 18:13:37 +01:00
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
2001-02-21 23:33:17 +01:00
void CGlassesPickup::renderPickup(DVECTOR *_pos)
2001-02-21 18:13:37 +01:00
{
2001-02-21 23:33:17 +01:00
SpriteBank *sprites;
sFrameHdr *fh;
int x,y;
2001-05-25 20:43:47 +02:00
sprites=CGameScene::getSpriteBank();
2001-02-21 23:33:17 +01:00
fh=sprites->getFrameHeader(FRM__GLASSES);
x=_pos->vx-(fh->W/2);
y=_pos->vy-(fh->H/2);
2001-04-19 22:46:43 +02:00
sprites->printFT4(fh,x,y,0,0,OTPOS__PICKUP_POS);
2001-02-23 22:40:22 +01:00
if(m_glint<=glasses_glintframes)
{
2001-03-29 22:53:10 +02:00
fh=sprites->getFrameHeader(glasses_glintFrames[(m_glint>>glasses_glintspeed)&0x07]);
2001-04-19 22:46:43 +02:00
sprites->printRotatedScaledSprite(fh,x+glasses_gxy.vx,y+glasses_gxy.vy,4095,4095,m_glintRot,OTPOS__PICKUP_POS-1);
2001-02-23 22:40:22 +01:00
}
2001-02-21 18:13:37 +01:00
}
2001-02-21 15:54:40 +01:00
/*===========================================================================
end */