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()
|
|
|
|
{
|
|
|
|
m_heading = m_fireHeading = 128;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if ( !m_animPlaying && m_frame != 0 )
|
|
|
|
{
|
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-05-02 20:40:41 +02:00
|
|
|
else if ( m_animNo == ANIM_BALLBLOB_IDLE )
|
2001-04-03 20:32:24 +02:00
|
|
|
{
|
2001-04-20 16:48:15 +02:00
|
|
|
moveX = 0;
|
|
|
|
moveY = 0;
|
|
|
|
|
|
|
|
processMovementModifier( _frames, moveX, moveY, moveVel, moveDist );
|
2001-04-03 20:32:24 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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-04-23 15:51:25 +02:00
|
|
|
groundHeight = m_layerCollision->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;
|
|
|
|
m_animPlaying = true;
|
2001-05-02 20:40:41 +02:00
|
|
|
m_animNo = ANIM_BALLBLOB_IDLE;
|
2001-04-23 15:51:25 +02:00
|
|
|
m_frame = 0;
|
2001-04-03 20:32:24 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-23 15:51:25 +02:00
|
|
|
m_velocity.vy = -( 5 << 8 );
|
|
|
|
m_animPlaying = true;
|
2001-05-02 20:40:41 +02:00
|
|
|
m_animNo = ANIM_BALLBLOB_IDLE;
|
2001-04-23 15:51:25 +02:00
|
|
|
m_frame = 0;
|
2001-04-03 20:32:24 +02:00
|
|
|
}
|
2001-04-23 15:51:25 +02:00
|
|
|
|
|
|
|
moveY = groundHeight;
|
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;
|
|
|
|
|
|
|
|
if ( m_npcPath.thinkFlat( Pos, &pathComplete, &waypointXDist, &waypointYDist, &waypointHeading ) )
|
2001-04-03 20:32:24 +02:00
|
|
|
{
|
2001-05-02 20:40:41 +02:00
|
|
|
if ( m_animNo != ANIM_BALLBLOB_IDLE)
|
2001-04-23 15:51:25 +02:00
|
|
|
{
|
|
|
|
m_animPlaying = true;
|
2001-05-02 20:40:41 +02:00
|
|
|
m_animNo = ANIM_BALLBLOB_IDLE;
|
2001-04-23 15:51:25 +02:00
|
|
|
m_frame = 0;
|
|
|
|
}
|
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
|
|
|
}
|