SBSPSS/source/jellfish/jellfish.cpp

166 lines
3.0 KiB
C++
Raw Permalink Normal View History

2001-05-10 16:00:29 +02:00
/*=========================================================================
jellfish.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __JELLFISH_JELLFISH_H__
#include "jellfish\jellfish.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __ENEMY_NSJBACK_H__
#include "enemy\nsjback.h"
#endif
2001-05-10 23:30:17 +02:00
#ifndef __ENEMY_NSJ2BACK_H__
#include "enemy\nsj2back.h"
#endif
2001-05-11 00:19:55 +02:00
#ifndef __ENEMY_NBUTTFLY_H__
#include "enemy\nbuttfly.h"
#endif
2001-05-10 16:00:29 +02:00
#ifndef __ENEMY_NPC_H__
#include "enemy\npc.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-05-25 20:43:47 +02:00
#include "game\game.h"
2001-05-10 16:00:29 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
u8 CJellyfishGenerator::m_jellyfishCount;
s32 CJellyfishGenerator::m_timer;
2001-05-10 18:47:35 +02:00
u8 CJellyfishGenerator::m_on;
2001-05-10 23:30:17 +02:00
u8 CJellyfishGenerator::m_level;
2001-05-10 16:00:29 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CJellyfishGenerator::init()
{
m_timer = 1 * GameState::getOneSecondInFrames();
m_jellyfishCount = 0;
2001-05-10 18:47:35 +02:00
m_on = true;
2001-05-10 23:30:17 +02:00
m_level = 1;
2001-05-10 18:47:35 +02:00
switch( CLevel::getCurrentChapter() )
{
case 1:
{
switch( CLevel::getCurrentChapterLevel() )
{
case 2:
{
2001-05-11 00:19:55 +02:00
m_level = 3;
2001-07-28 19:00:06 +02:00
m_on = false;
2001-05-10 23:30:17 +02:00
break;
}
case 4:
{
m_level = 2;
break;
2001-05-10 18:47:35 +02:00
}
}
break;
}
}
2001-05-10 16:00:29 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CJellyfishGenerator::think( int _frames, CLevel *level )
{
2001-05-10 18:47:35 +02:00
if ( m_on )
2001-05-10 16:00:29 +02:00
{
2001-05-10 18:47:35 +02:00
if ( m_timer <= 0 )
2001-05-10 16:00:29 +02:00
{
2001-05-10 18:47:35 +02:00
if ( m_jellyfishCount < 10 )
2001-05-10 16:00:29 +02:00
{
2001-05-10 18:47:35 +02:00
// add jellyfish
m_timer = 1 * GameState::getOneSecondInFrames();
m_jellyfishCount++;
2001-05-11 00:19:55 +02:00
CNpcEnemy *enemy = NULL;
2001-05-10 23:30:17 +02:00
2001-05-11 00:19:55 +02:00
switch( m_level )
2001-05-10 23:30:17 +02:00
{
2001-05-11 00:19:55 +02:00
case 1:
case 2:
{
2001-06-13 18:04:46 +02:00
enemy=CNpcEnemy::Create( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND );
2001-05-11 00:19:55 +02:00
break;
}
case 3:
{
2001-06-13 18:04:46 +02:00
enemy=CNpcEnemy::Create( CNpcEnemy::NPC_BUTTERFLY_BACKGROUND );
2001-05-11 00:19:55 +02:00
break;
}
2001-05-10 23:30:17 +02:00
}
2001-07-23 21:26:37 +02:00
DVECTOR const &offset = CLevel::getCameraPos();
2001-05-10 18:47:35 +02:00
DVECTOR startPos;
2001-05-10 23:30:17 +02:00
2001-05-21 20:36:26 +02:00
CNpcSmallJellyfishBackgroundEnemy *jfish = ( CNpcSmallJellyfishBackgroundEnemy * ) enemy;
2001-05-11 00:19:55 +02:00
2001-05-21 20:36:26 +02:00
if ( ( getRnd() % 10 ) > 4 )
{
jfish->setTargetHeading( 0 );
startPos.vx = offset.vx - 20;
}
else
{
jfish->setTargetHeading( 2048 );
startPos.vx = offset.vx + VidGetScrW() + 20;
2001-05-10 18:47:35 +02:00
}
startPos.vy = offset.vy + ( getRnd() % VidGetScrH() );
enemy->setStartPos( startPos.vx >> 4, startPos.vy >> 4 );
enemy->postInit();
2001-05-11 00:39:23 +02:00
enemy->updateCollisionArea();
2001-05-10 16:00:29 +02:00
}
}
2001-05-10 18:47:35 +02:00
else
{
m_timer -= _frames;
}
2001-05-10 16:00:29 +02:00
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CJellyfishGenerator::decCounter()
{
if ( m_jellyfishCount > 0 )
{
m_jellyfishCount--;
}
}