SBSPSS/source/platform/pfishhk.cpp

151 lines
2.8 KiB
C++
Raw Normal View History

2001-04-23 20:18:19 +02:00
/*=========================================================================
pfishhk.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFISHHK_H__
#include "platform\pfishhk.h"
#endif
2001-05-04 18:34:57 +02:00
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-05-09 15:22:04 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-05-04 18:34:57 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-04-23 20:18:19 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-25 22:04:25 +02:00
void CNpcFishHookPlatform::postInit()
{
2001-05-05 15:54:34 +02:00
CNpcPlatform::postInit();
2001-04-25 22:04:25 +02:00
m_isMoving = false;
2001-05-14 17:14:39 +02:00
m_isResetting = false;
2001-04-25 22:04:25 +02:00
m_isShuttingDown = false;
2001-05-09 15:22:04 +02:00
m_lineBase.vx = Pos.vx;
m_lineBase.vy = 0;
2001-04-25 22:04:25 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-23 20:18:19 +02:00
void CNpcFishHookPlatform::processLifetime( int _frames )
{
if ( m_contact )
{
m_isMoving = true;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFishHookPlatform::processMovement( int _frames )
{
2001-04-23 22:40:13 +02:00
if ( m_isMoving )
2001-04-23 20:18:19 +02:00
{
2001-05-21 23:16:42 +02:00
CSoundMediator::playSfx( CSoundMediator::SFX_FISH_HOOK_MOVE );
2001-05-14 17:14:39 +02:00
if ( m_isResetting )
{
Pos.vy += 2 * _frames;
if ( Pos.vy > m_base.vy )
{
Pos.vy = m_base.vy;
2001-04-23 22:40:13 +02:00
2001-05-14 17:14:39 +02:00
m_isResetting = false;
m_isMoving = false;
}
}
else
2001-04-23 22:40:13 +02:00
{
2001-05-14 17:14:39 +02:00
Pos.vy -= m_speed * _frames;
if ( Pos.vy < 0 )
{
m_isResetting = true;
}
2001-04-23 22:40:13 +02:00
}
2001-04-23 20:18:19 +02:00
}
2001-05-09 15:22:04 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFishHookPlatform::render()
{
int x1,y1,x2,y2;
if ( m_isActive )
{
CPlatformThing::render();
2001-05-10 18:16:57 +02:00
DVECTOR &renderPos=getRenderPos();
if (canRender())
2001-05-09 15:22:04 +02:00
{
2001-05-10 18:16:57 +02:00
m_modelGfx->Render(renderPos);
2001-05-09 15:22:04 +02:00
}
2001-05-10 18:16:57 +02:00
// draw Line (Literally!!)
if (renderPos.vx>0 && renderPos.vx<512)
{
DVECTOR const &CamPos=CLevel::getCameraPos();
x1 = renderPos.vx;
x2 = m_lineBase.vx - CamPos.vx;
2001-05-09 15:22:04 +02:00
2001-05-10 18:16:57 +02:00
if ( x1 > x2 )
{
int tempX = x1;
x1 = x2;
x2 = tempX;
}
2001-05-09 15:22:04 +02:00
2001-05-10 18:16:57 +02:00
y1 = renderPos.vy;
y2 = m_lineBase.vy - CamPos.vy;
2001-05-09 15:22:04 +02:00
2001-05-10 18:16:57 +02:00
if ( y1 > y2 )
{
int tempY = y1;
y1 = y2;
y2 = tempY;
}
2001-05-09 15:22:04 +02:00
2001-05-10 18:16:57 +02:00
if ( y1 < 0 )
2001-05-09 15:22:04 +02:00
{
2001-05-10 18:16:57 +02:00
y1 = 0;
2001-05-09 15:22:04 +02:00
}
2001-05-10 18:16:57 +02:00
if ( y2 > VidGetScrH() )
{
y2 = VidGetScrH();
}
DrawLine( x1, y1, x2, y2, 0, 0, 0, 0 );
2001-05-09 15:22:04 +02:00
}
}
2001-05-10 18:16:57 +02:00
2001-05-09 15:22:04 +02:00
}
2001-05-14 20:48:54 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CRECT *CNpcFishHookPlatform::getThinkBBox()
{
CRECT objThinkBox = getCollisionArea();
sBBox &thinkBBox = CThingManager::getThinkBBox();
objThinkBox.y2 = thinkBBox.YMin + 1;
return &objThinkBox;
}