This commit is contained in:
Charles 2001-05-05 13:53:08 +00:00
parent 6120b9bab8
commit d81378013f
4 changed files with 220 additions and 0 deletions

81
source/hazard/hbwheel.cpp Normal file
View File

@ -0,0 +1,81 @@
/*=========================================================================
hbwheel.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HBWHEEL_H__
#include "hazard\hbwheel.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef __LEVEL_LEVEL_H__
#include "level\level.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelHazard::init()
{
CNpcHazard::init();
m_rotation = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelHazard::processMovement( int _frames )
{
m_rotation += 10 * _frames;
m_rotation &= 4095;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelHazard::render()
{
CHazardThing::render();
// Render
DVECTOR renderPos;
DVECTOR offset = CLevel::getCameraPos();
renderPos.vx = Pos.vx - offset.vx;
renderPos.vy = Pos.vy - offset.vy;
if ( renderPos.vx >= 0 && renderPos.vx <= VidGetScrW() )
{
if ( renderPos.vy >= 0 && renderPos.vy <= VidGetScrH() )
{
SVECTOR rotation;
rotation.vx = 0;
rotation.vy = 0;
rotation.vz = m_rotation;
VECTOR scale;
scale.vx = ONE;
scale.vy = ONE;
scale.vz = ONE;
m_modelGfx->Render(renderPos,&rotation,&scale);
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelHazard::collidedWith( CThing *_thisThing )
{
// do not collide
}

33
source/hazard/hbwheel.h Normal file
View File

@ -0,0 +1,33 @@
/*=========================================================================
hbwheel.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __HAZARD_HBWHEEL_H__
#define __HAZARD_HBWHEEL_H__
#ifndef __HAZARD_HAZARD_H__
#include "hazard\hazard.h"
#endif
class CNpcBigWheelHazard : public CNpcHazard
{
public:
void init();
virtual void render();
protected:
void processMovement( int _frames );
virtual void collidedWith(CThing *_thisThing);
s16 m_rotation;
};
#endif

View File

@ -0,0 +1,78 @@
/*=========================================================================
pbwheel.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PBWHEEL_H__
#include "platform\pbwheel.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelPlatform::processMovement( int _frames )
{
m_rotation += m_data[m_type].speed * _frames;
m_rotation &= 4095;
Pos.vx = m_base.vx + ( ( m_extension * rcos( m_rotation ) ) >> 12 );
Pos.vy = m_base.vy + ( ( m_extension * rsin( m_rotation ) ) >> 12 );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBigWheelPlatform::setWaypoints( sThingPlatform *ThisPlatform )
{
int pointNum;
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 newXPos, newYPos;
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
if ( ThisPlatform->PointCount > 1 )
{
newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR pivotPos;
pivotPos.vx = newXPos << 4;
pivotPos.vy = newYPos << 4;
s32 xDist = startPos.vx - pivotPos.vx;
s32 yDist = startPos.vy - pivotPos.vy;
init( pivotPos );
m_rotation = ratan2( abs( yDist ), abs( xDist ) );
m_extension = isqrt2( ( xDist * xDist ) + ( yDist * yDist ) );
}
else
{
init( startPos );
}
}

28
source/platform/pbwheel.h Normal file
View File

@ -0,0 +1,28 @@
/*=========================================================================
pbwheel.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PBWHEEL_H__
#define __PLATFORM_PBWHEEL_H__
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
class CNpcBigWheelPlatform : public CNpcPlatform
{
protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames );
};
#endif