SBSPSS/source/projectl/projectl.cpp

793 lines
18 KiB
C++
Raw Normal View History

2001-01-22 17:01:49 +01:00
/*=========================================================================
projectl.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2000 Climax Development Ltd
===========================================================================*/
#ifndef __PROJECTL_PROJECTL_H__
#include "projectl\projectl.h"
#endif
#ifndef __GFX_SPRBANK_H__
#include "gfx\sprbank.h"
#endif
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
#endif
#ifndef __FILE_EQUATES_H__
#include <biglump.h>
#endif
2001-04-20 16:53:35 +02:00
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
2001-01-22 17:01:49 +01:00
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-01-22 23:24:53 +01:00
#ifndef __PLAYER_PLAYER_H__
#include "player\player.h"
#endif
2001-04-12 18:33:48 +02:00
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
2001-06-18 15:47:50 +02:00
2001-05-16 22:46:54 +02:00
#include "gfx\otpos.h"
2001-06-18 15:47:50 +02:00
#include "fx\fx.h"
2001-04-12 18:33:48 +02:00
2001-01-22 17:01:49 +01:00
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CProjectile *CProjectile::Create()
{
CProjectile *projectile;
projectile = (CProjectile*)CThingManager::GetThing(TYPE_ENEMYPROJECTILE,0);
if ( !projectile )
{
projectile = new ("enemy projectile") CProjectile;
}
ASSERT(projectile);
2001-06-26 18:00:36 +02:00
projectile->setThingSubType(0);
2001-06-14 18:07:48 +02:00
return( projectile );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::init()
{
2001-02-28 23:03:18 +01:00
CEnemyProjectileThing::init();
2001-05-17 17:27:03 +02:00
m_spriteFrame = FRM__SPIKE;
2001-01-22 17:01:49 +01:00
2001-05-17 17:27:03 +02:00
m_initHeading = m_heading = 0;
2001-01-22 17:01:49 +01:00
m_lifetime = GameState::getOneSecondInFrames() * 2;
2001-01-22 23:24:53 +01:00
m_movementType = PROJECTILE_DUMBFIRE;
m_lifetimeType = PROJECTILE_FINITE_LIFE;
m_state = PROJECTILE_ATTACK;
m_turnSpeed = 256;
2001-02-08 21:00:58 +01:00
m_extension = 0;
2001-05-16 22:46:54 +02:00
m_ot = OTPOS__ACTOR_POS;
2001-05-21 20:20:33 +02:00
m_speed = 3;
2001-05-11 00:39:23 +02:00
updateCollisionArea();
2001-01-22 17:01:49 +01:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::init( DVECTOR initPos, s16 initHeading )
{
init();
2001-05-17 17:27:03 +02:00
m_initHeading = m_heading = initHeading;
2001-02-08 21:00:58 +01:00
m_initPos = Pos = initPos;
2001-01-22 17:01:49 +01:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 23:24:53 +01:00
void CProjectile::init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TYPE initMoveType, PROJECTILE_LIFETIME_TYPE initLifeType )
{
init( initPos, initHeading );
m_movementType = initMoveType;
m_lifetimeType = initLifeType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-02-08 16:42:59 +01:00
void CProjectile::init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TYPE initMoveType, PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime )
{
init( initPos, initHeading, initMoveType, initLifeType );
m_lifetime = initLifetime;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::shutdown()
{
2001-04-25 21:52:35 +02:00
CEnemyProjectileThing::shutdown();
}
2001-02-28 23:03:18 +01:00
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-17 17:27:03 +02:00
void CProjectile::setGraphic( int frame )
{
m_spriteFrame = frame;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 23:24:53 +01:00
bool CProjectile::processTargetSeek( int _frames, DVECTOR targetPos )
{
s32 moveX = 0, moveY = 0;
s16 moveDist = 0;
s32 moveVel = 0;
s32 xDist, yDist;
s32 xDistSqr, yDistSqr;
xDist = targetPos.vx - this->Pos.vx;
xDistSqr = xDist * xDist;
yDist = targetPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
//if ( xDistSqr + yDistSqr > 22500 )
//{
//this->m_controlFunc = NPC_CONTROL_MOVEMENT;
//}
//else
{
s16 headingToTarget = ratan2( yDist, xDist );
s16 maxTurnRate = m_turnSpeed;
s16 decDir, incDir;
decDir = m_heading - headingToTarget;
if ( decDir < 0 )
{
decDir += ONE;
}
incDir = headingToTarget - m_heading;
if ( incDir < 0 )
{
incDir += ONE;
}
if ( decDir < incDir )
{
moveDist = -decDir;
}
else
{
moveDist = incDir;
}
if ( moveDist < -maxTurnRate )
{
moveDist = -maxTurnRate;
}
else if ( moveDist > maxTurnRate )
{
moveDist = maxTurnRate;
}
m_heading += moveDist;
2001-04-10 01:53:00 +02:00
m_heading &= 4095;
2001-01-22 23:24:53 +01:00
2001-05-21 20:20:33 +02:00
s32 preShiftX = _frames * m_speed * rcos( m_heading );
s32 preShiftY = _frames * m_speed * rsin( m_heading );
2001-01-22 23:24:53 +01:00
moveX = preShiftX >> 12;
if ( !moveX && preShiftX )
{
moveX = preShiftX / abs( preShiftX );
}
moveY = preShiftY >> 12;
if ( !moveY && preShiftY )
{
moveY = preShiftY / abs( preShiftY );
}
Pos.vx += moveX;
Pos.vy += moveY;
}
xDist = targetPos.vx - this->Pos.vx;
xDistSqr = xDist * xDist;
yDist = targetPos.vy - this->Pos.vy;
yDistSqr = yDist * yDist;
if ( xDistSqr + yDistSqr < 100 )
{
return( true );
}
else
{
return( false );
}
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-04 00:01:52 +02:00
void CProjectile::setMovementType( PROJECTILE_MOVEMENT_TYPE moveType )
{
m_movementType = moveType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-04 00:01:52 +02:00
CProjectile::PROJECTILE_MOVEMENT_TYPE CProjectile::getMovementType()
{
return( m_movementType );
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-04 00:01:52 +02:00
void CProjectile::setState( PROJECTILE_STATE newState )
{
m_state = newState;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-04 00:01:52 +02:00
void CProjectile::setPosition( DVECTOR newPos )
{
Pos = newPos;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-04 17:53:44 +02:00
void CProjectile::setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType )
{
m_lifetimeType = lifeType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::think(int _frames)
{
2001-04-30 20:55:38 +02:00
if ( _frames > 2 )
{
_frames = 2;
}
2001-02-28 23:03:18 +01:00
CEnemyProjectileThing::think( _frames );
2001-01-22 23:24:53 +01:00
switch( m_movementType )
{
2001-04-04 00:01:52 +02:00
case PROJECTILE_FIXED:
{
// don't move at all
break;
}
2001-01-22 23:24:53 +01:00
case PROJECTILE_USER_SEEK:
{
2001-05-25 20:43:47 +02:00
if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
2001-01-22 23:24:53 +01:00
{
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-04-12 16:55:55 +02:00
}
else
{
switch( m_state )
2001-01-22 23:24:53 +01:00
{
2001-04-12 16:55:55 +02:00
case PROJECTILE_RETURN:
2001-01-22 23:24:53 +01:00
{
2001-05-17 17:27:03 +02:00
if ( processTargetSeek( _frames, m_initPos ) )
2001-04-12 16:55:55 +02:00
{
2001-05-21 16:52:09 +02:00
CThing *Parent=getParent();
2001-04-12 16:55:55 +02:00
Parent->processEvent( PROJECTILE_RETURNED_TO_SOURCE_EVENT, this );
2001-05-17 17:27:03 +02:00
m_heading = m_initHeading;
2001-04-12 16:55:55 +02:00
}
break;
2001-01-22 23:24:53 +01:00
}
2001-04-12 16:55:55 +02:00
case PROJECTILE_ATTACK:
default:
{
CPlayer *player = GameScene.getPlayer();
DVECTOR playerPos = player->getPos();
2001-01-22 23:24:53 +01:00
2001-04-12 16:55:55 +02:00
if ( processTargetSeek( _frames, playerPos ) )
{
m_state = PROJECTILE_RETURN;
}
2001-01-22 23:24:53 +01:00
2001-04-12 16:55:55 +02:00
break;
2001-01-22 23:24:53 +01:00
}
}
}
2001-01-22 17:01:49 +01:00
2001-01-22 23:24:53 +01:00
break;
}
2001-02-08 16:34:18 +01:00
case PROJECTILE_GAS_CLOUD:
{
2001-02-08 21:00:58 +01:00
u16 targetExtension = 100 << 8;
if ( m_extension < targetExtension )
{
m_extension += ( ( targetExtension - m_extension ) * _frames ) >> 8;
Pos = m_initPos;
Pos.vx += ( m_extension * rcos( m_heading ) ) >> 20;
Pos.vy += ( m_extension * rsin( m_heading ) ) >> 20;
}
else
{
// expand
}
2001-02-08 16:34:18 +01:00
break;
}
2001-06-18 15:47:50 +02:00
case PROJECTILE_MINE:
{
s32 moveY = _frames * m_speed;
s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy + moveY, 16 );
if ( groundHeight < 0 )
{
moveY = groundHeight;
}
Pos.vy += moveY;
}
2001-01-22 23:24:53 +01:00
case PROJECTILE_DUMBFIRE:
default:
{
2001-05-25 20:43:47 +02:00
if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
2001-04-12 16:55:55 +02:00
{
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-04-12 16:55:55 +02:00
}
else
{
2001-05-21 20:20:33 +02:00
Pos.vx += ( _frames * m_speed * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * m_speed * rsin( m_heading ) ) >> 12;
2001-04-12 16:55:55 +02:00
}
2001-01-22 23:24:53 +01:00
break;
}
}
if ( m_lifetimeType == PROJECTILE_FINITE_LIFE )
2001-01-22 17:01:49 +01:00
{
2001-01-22 23:24:53 +01:00
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-06-18 15:47:50 +02:00
if ( m_movementType == PROJECTILE_MINE )
{
CFX::Create( CFX::FX_TYPE_EXPLODE, Pos );
}
2001-01-22 23:24:53 +01:00
}
2001-01-22 17:01:49 +01:00
}
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::render()
{
2001-02-28 23:03:18 +01:00
CEnemyProjectileThing::render();
2001-04-09 23:00:24 +02:00
sFrameHdr *frameHdr;
2001-01-22 17:01:49 +01:00
DVECTOR offset;
int x,y;
int scrnWidth = VidGetScrW();
int scrnHeight = VidGetScrH();
2001-05-25 20:43:47 +02:00
int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( m_spriteFrame );
int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( m_spriteFrame );
2001-01-22 17:01:49 +01:00
offset = getScreenOffset();
2001-04-09 23:00:24 +02:00
x = Pos.vx - offset.vx /*+ ( scrnWidth >> 1 ) - ( spriteWidth >> 1 )*/;
y = Pos.vy - offset.vy /*+ ( scrnHeight >> 1 ) - ( spriteHeight >> 1 )*/;
2001-01-22 17:01:49 +01:00
2001-02-13 16:27:40 +01:00
if ( x < -spriteWidth || y < -spriteHeight || x > scrnWidth || y > scrnHeight )
{
return;
}
2001-05-25 20:43:47 +02:00
//CGameScene::getSpriteBank()->printFT4(FRM__SPIKE,x,y,0,0,0);
2001-04-09 23:00:24 +02:00
2001-05-25 20:43:47 +02:00
frameHdr = CGameScene::getSpriteBank()->getFrameHeader( m_spriteFrame );
2001-04-09 23:00:24 +02:00
2001-05-25 20:43:47 +02:00
CGameScene::getSpriteBank()->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, m_heading, m_ot );
2001-01-22 17:01:49 +01:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
DVECTOR CProjectile::getScreenOffset()
{
return CLevel::getCameraPos();
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-01-22 17:01:49 +01:00
void CProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing )
{
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-12 18:33:48 +02:00
void CProjectile::collidedWith(CThing *_thisThing)
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
player->takeDamage( DAMAGE__HIT_ENEMY );
2001-04-20 17:21:26 +02:00
if ( m_lifetimeType != PROJECTILE_INFINITE_LIFE )
{
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-06-18 15:47:50 +02:00
if ( m_movementType == PROJECTILE_MINE )
{
CFX::Create( CFX::FX_TYPE_EXPLODE, Pos );
}
2001-04-20 17:21:26 +02:00
}
2001-04-12 18:33:48 +02:00
break;
}
default:
ASSERT(0);
break;
}
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CPlayerProjectile *CPlayerProjectile::Create()
{
CPlayerProjectile *projectile;
projectile = (CPlayerProjectile*)CThingManager::GetThing(TYPE_PLAYERPROJECTILE,0);
if ( !projectile )
{
projectile = new ("player projectile") CPlayerProjectile;
}
ASSERT(projectile);
2001-06-26 18:00:36 +02:00
projectile->setThingSubType(0);
2001-06-14 18:07:48 +02:00
return( projectile );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::init()
{
CPlayerProjectileThing::init();
m_heading = 0;
m_lifetime = GameState::getOneSecondInFrames() * 2;
m_movementType = PLAYER_PROJECTILE_DUMBFIRE;
m_lifetimeType = PLAYER_PROJECTILE_FINITE_LIFE;
m_turnSpeed = 256;
m_extension = 0;
2001-04-20 23:29:11 +02:00
m_frame = 0;
m_reversed = 0;
2001-04-07 00:21:01 +02:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading )
{
init();
m_heading = initHeading;
m_initPos = Pos = initPos;
2001-06-11 17:42:07 +02:00
m_vertVelocity = 0;
m_bounceCount = 0;
m_hitTarget = false;
2001-04-20 23:29:11 +02:00
2001-05-15 23:28:06 +02:00
if ( m_heading > 1024 && m_heading < 3072 )
2001-04-20 23:29:11 +02:00
{
m_reversed = 1;
}
2001-05-17 21:28:08 +02:00
m_RGB.r = 0;
m_RGB.g = 0;
m_RGB.b = 0;
2001-04-07 00:21:01 +02:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType )
{
init( initPos, initHeading );
m_movementType = initMoveType;
m_lifetimeType = initLifeType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime )
{
init( initPos, initHeading, initMoveType, initLifeType );
m_lifetime = initLifetime;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::shutdown()
{
2001-04-25 17:41:29 +02:00
2001-04-25 21:52:35 +02:00
CPlayerProjectileThing::shutdown();
}
2001-04-07 00:21:01 +02:00
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType )
{
m_movementType = moveType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
CPlayerProjectile::PLAYER_PROJECTILE_MOVEMENT_TYPE CPlayerProjectile::getMovementType()
{
return( m_movementType );
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::setPosition( DVECTOR newPos )
{
Pos = newPos;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType )
{
m_lifetimeType = lifeType;
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::think(int _frames)
{
2001-04-30 20:55:38 +02:00
if ( _frames > 2 )
{
_frames = 2;
}
2001-04-07 00:21:01 +02:00
CPlayerProjectileThing::think( _frames );
2001-05-15 23:28:06 +02:00
/*m_frame += _frames;
2001-04-20 23:29:11 +02:00
2001-05-11 00:42:58 +02:00
if ( m_frame > ( FRM_JELLYFISH1_SWIM6 - FRM_JELLYFISH1_SWIM1 ) )
2001-04-20 23:29:11 +02:00
{
2001-05-11 00:42:58 +02:00
m_frame = 0;
2001-05-15 23:28:06 +02:00
}*/
2001-04-20 23:29:11 +02:00
2001-04-07 00:21:01 +02:00
switch( m_movementType )
{
2001-06-11 17:42:07 +02:00
case PLAYER_PROJECTILE_BOUNCING:
{
if ( !m_hitTarget )
{
2001-06-13 18:04:46 +02:00
Pos.vx += ( _frames * 5 * rcos( m_heading ) ) >> 12;
2001-06-11 17:42:07 +02:00
2001-06-13 18:04:46 +02:00
m_vertVelocity += 3 << 7;
2001-06-11 17:42:07 +02:00
2001-06-13 18:04:46 +02:00
if ( m_vertVelocity > ( 7 << 8 ) )
2001-06-11 17:42:07 +02:00
{
2001-06-13 18:04:46 +02:00
m_vertVelocity = 7 << 8;
2001-06-11 17:42:07 +02:00
}
2001-06-13 18:04:46 +02:00
else if ( m_vertVelocity < -( 7 << 8 ) )
2001-06-11 17:42:07 +02:00
{
2001-06-13 18:04:46 +02:00
m_vertVelocity = -( 7 << 8 );
2001-06-11 17:42:07 +02:00
}
s16 moveY = ( m_vertVelocity >> 8 ) * _frames;
2001-06-13 18:04:46 +02:00
s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, moveY );
2001-06-11 17:42:07 +02:00
2001-06-13 18:04:46 +02:00
if ( groundHeight < moveY )
2001-06-11 17:42:07 +02:00
{
// destroy destructable tiles
CLevel &level = GameScene.GetLevel();
level.destroyMapArea( Pos );
if ( groundHeight < -16 )
{
m_hitTarget = true;
m_lifetimeType = PLAYER_PROJECTILE_FINITE_LIFE;
m_lifetime = GameState::getOneSecondInFrames() >> 2;
}
else
{
// reverse vertical velocity
m_vertVelocity = -m_vertVelocity;
if ( m_bounceCount > 2 )
{
m_hitTarget = true;
m_lifetimeType = PLAYER_PROJECTILE_FINITE_LIFE;
m_lifetime = GameState::getOneSecondInFrames() >> 2;
}
else
{
m_bounceCount++;
}
}
}
else
{
Pos.vy += moveY;
}
}
break;
}
2001-04-07 00:21:01 +02:00
case PLAYER_PROJECTILE_DUMBFIRE:
default:
{
2001-05-25 20:43:47 +02:00
if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) )
2001-04-12 16:55:55 +02:00
{
2001-05-16 21:55:28 +02:00
// destroy destructable tiles
CLevel &level = GameScene.GetLevel();
2001-06-11 17:42:07 +02:00
2001-05-16 21:55:28 +02:00
level.destroyMapArea( Pos );
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-04-12 16:55:55 +02:00
}
else
{
2001-05-09 23:31:14 +02:00
Pos.vx += ( _frames * 5 * rcos( m_heading ) ) >> 12;
Pos.vy += ( _frames * 5 * rsin( m_heading ) ) >> 12;
2001-04-12 16:55:55 +02:00
}
2001-04-07 00:21:01 +02:00
break;
}
}
if ( m_lifetimeType == PLAYER_PROJECTILE_FINITE_LIFE )
{
m_lifetime -= _frames;
if ( m_lifetime <= 0 )
{
2001-04-25 21:52:35 +02:00
setToShutdown();
2001-04-07 00:21:01 +02:00
}
}
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::render()
{
CPlayerProjectileThing::render();
DVECTOR offset;
int x,y;
int scrnWidth = VidGetScrW();
int scrnHeight = VidGetScrH();
offset = getScreenOffset();
2001-06-11 17:42:07 +02:00
if ( m_hitTarget )
2001-05-03 15:26:46 +02:00
{
2001-06-11 17:42:07 +02:00
x = Pos.vx - offset.vx;
y = Pos.vy - offset.vy;
SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, x, y, 4096 << 1, 4096 << 1, 0, 0 );
setRGB0( SprFrame, m_RGB.r, m_RGB.g, m_RGB.b );
2001-05-03 15:26:46 +02:00
}
else
{
2001-06-11 17:42:07 +02:00
int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(m_frame);
int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(m_frame);
2001-05-03 15:26:46 +02:00
2001-06-11 17:42:07 +02:00
if ( m_reversed )
{
x = Pos.vx - offset.vx + ( spriteWidth >> 1 );
}
else
{
x = Pos.vx - offset.vx - ( spriteWidth >> 1 );
}
2001-04-07 00:21:01 +02:00
2001-06-11 17:42:07 +02:00
y = Pos.vy - offset.vy - ( spriteHeight >> 1 );
if ( x < -spriteWidth || y < -spriteHeight || x > scrnWidth || y > scrnHeight )
{
return;
}
2001-04-07 00:21:01 +02:00
2001-06-11 17:42:07 +02:00
SprFrame = CGameScene::getSpriteBank()->printFT4(FRM_JELLYFISH1_SWIM1 + m_frame,x,y,m_reversed,0,0);
setRGB0( SprFrame, m_RGB.r, m_RGB.g, m_RGB.b );
}
2001-04-07 00:21:01 +02:00
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
DVECTOR CPlayerProjectile::getScreenOffset()
{
return CLevel::getCameraPos();
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-07 00:21:01 +02:00
void CPlayerProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing )
{
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-12 18:33:48 +02:00
void CPlayerProjectile::collidedWith(CThing *_thisThing)
{
switch(_thisThing->getThingType())
{
case TYPE_ENEMY:
{
CNpcEnemy *enemy = (CNpcEnemy *) _thisThing;
2001-05-15 22:21:05 +02:00
if ( enemy->hasBeenAttacked() )
{
setToShutdown();
}
2001-05-03 15:26:46 +02:00
2001-04-12 18:33:48 +02:00
break;
}
default:
ASSERT(0);
break;
}
}
2001-06-14 18:07:48 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-05-17 22:04:57 +02:00
void CPlayerProjectile::setRGB( u32 new_RGB )
{
m_RGB.r = new_RGB & 255;
m_RGB.g = ( new_RGB >> 8 ) & 255;
m_RGB.b = ( new_RGB >> 16 ) & 255;
}
2001-04-07 00:21:01 +02:00
/*****************************************************************************/