SBSPSS/source/enemy/nbblob.cpp

112 lines
2.0 KiB
C++
Raw Normal View History

2001-04-03 17:57:13 +02:00
/*=========================================================================
nbblob.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
2001-04-20 16:48:15 +02:00
#ifndef __ENEMY_NBBLOB_H__
#include "enemy\nbblob.h"
#endif
2001-04-03 20:32:24 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __ANIM_BALLBLOB_HEADER__
#include <ACTOR_BALLBLOB_ANIM.h>
#endif
2001-04-20 22:22:16 +02:00
void CNpcBallBlobEnemy::postInit()
{
2001-05-16 21:04:40 +02:00
m_heading = 128;
2001-04-20 22:22:16 +02:00
m_npcPath.setPathType( CNpcPath::PONG_PATH );
2001-04-23 15:51:25 +02:00
m_velocity.vx = 0;
m_velocity.vy = -5;
2001-04-20 22:22:16 +02:00
}
2001-04-20 16:48:15 +02:00
void CNpcBallBlobEnemy::processMovement( int _frames )
2001-04-03 17:57:13 +02:00
{
2001-04-20 16:48:15 +02:00
s32 moveX = 0, moveY = 0;
s32 moveVel = 0;
s32 moveDist = 0;
2001-04-03 20:32:24 +02:00
s32 waypointXDist;
s32 waypointYDist;
s32 waypointHeading;
2001-04-23 15:51:25 +02:00
s32 groundHeight;
2001-04-03 20:32:24 +02:00
2001-05-22 16:00:18 +02:00
if ( !m_animPlaying )
2001-04-03 20:32:24 +02:00
{
2001-05-22 16:00:18 +02:00
m_animPlaying = true;
2001-05-02 20:40:41 +02:00
m_animNo = ANIM_BALLBLOB_IDLE;
2001-04-03 20:32:24 +02:00
m_frame = 0;
}
2001-04-23 15:51:25 +02:00
// deal with vertical
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
m_velocity.vy += 128;
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
if ( m_velocity.vy > ( 5 << 8 ) )
{
m_velocity.vy = 5 << 8;
}
else if ( m_velocity.vy < -( 5 << 8 ) )
{
m_velocity.vy = -( 5 << 8 );
}
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
moveY = ( m_velocity.vy >> 8 ) * _frames;
2001-04-03 20:32:24 +02:00
2001-05-25 20:43:47 +02:00
groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
if ( groundHeight < 0 )
{
if ( m_velocity.vy > 0 )
{
m_velocity.vy = -m_velocity.vy;
2001-04-03 20:32:24 +02:00
}
else
{
2001-04-23 15:51:25 +02:00
m_velocity.vy = -( 5 << 8 );
2001-04-03 20:32:24 +02:00
}
2001-04-23 15:51:25 +02:00
moveY = groundHeight;
2001-06-01 18:30:37 +02:00
if ( m_data[m_type].moveSfx < CSoundMediator::NUM_SFXIDS )
{
2001-06-18 21:06:43 +02:00
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( m_data[m_type].moveSfx, true );
}
2001-06-01 18:30:37 +02:00
}
2001-04-03 20:32:24 +02:00
}
2001-04-23 15:51:25 +02:00
// deal with horizontal
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
bool pathComplete;
2001-05-22 16:00:18 +02:00
m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading );
2001-04-03 20:32:24 +02:00
2001-04-23 15:51:25 +02:00
if ( waypointHeading == 0 )
2001-04-03 20:32:24 +02:00
{
2001-05-09 23:27:23 +02:00
moveX = m_speed * _frames;
2001-04-03 20:32:24 +02:00
}
2001-04-23 15:51:25 +02:00
else
2001-04-03 20:32:24 +02:00
{
2001-05-09 23:27:23 +02:00
moveX = -m_speed * _frames;
2001-04-03 20:32:24 +02:00
}
2001-04-20 16:48:15 +02:00
processMovementModifier( _frames, moveX, moveY, moveVel, moveDist );
2001-04-03 17:57:13 +02:00
}