diff --git a/source/hazard/hbwheel.cpp b/source/hazard/hbwheel.cpp new file mode 100644 index 000000000..36d7028a6 --- /dev/null +++ b/source/hazard/hbwheel.cpp @@ -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 +} diff --git a/source/hazard/hbwheel.h b/source/hazard/hbwheel.h new file mode 100644 index 000000000..dba5b1ebe --- /dev/null +++ b/source/hazard/hbwheel.h @@ -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 \ No newline at end of file diff --git a/source/platform/pbwheel.cpp b/source/platform/pbwheel.cpp new file mode 100644 index 000000000..4e1d134c9 --- /dev/null +++ b/source/platform/pbwheel.cpp @@ -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 ); + } +} diff --git a/source/platform/pbwheel.h b/source/platform/pbwheel.h new file mode 100644 index 000000000..376d59d60 --- /dev/null +++ b/source/platform/pbwheel.h @@ -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 \ No newline at end of file