diff --git a/source/hazard/hdbarrel.cpp b/source/hazard/hdbarrel.cpp index 26be57bc1..285ae51bd 100644 --- a/source/hazard/hdbarrel.cpp +++ b/source/hazard/hdbarrel.cpp @@ -23,6 +23,14 @@ #include "platform\platform.h" #endif +#ifndef __VID_HEADER_ +#include "system\vid.h" +#endif + +#ifndef __LEVEL_LEVEL_H__ +#include "level\level.h" +#endif + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcDualPlatformBarrelHazard::init() @@ -30,6 +38,9 @@ void CNpcDualPlatformBarrelHazard::init() CNpcHazard::init(); m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH ); + + m_rotation = 0; + m_rotationDir = 1; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -115,6 +126,18 @@ void CNpcDualPlatformBarrelHazard::processMovement( int _frames ) } } + if ( moveX ) + { + m_rotationDir = abs( moveX ) / moveX; + } + else + { + m_rotationDir = 0; + } + + m_rotation += m_rotationDir * 64 * _frames; + m_rotation &= 4095; + Pos.vx += moveX; Pos.vy += moveY; @@ -127,4 +150,42 @@ void CNpcDualPlatformBarrelHazard::processMovement( int _frames ) Pos = m_base; m_npcPath.resetPath(); } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcDualPlatformBarrelHazard::render() +{ + CHazardThing::render(); + + // Render + DVECTOR renderPos; + DVECTOR offset = CLevel::getCameraPos(); + + renderPos.vx = Pos.vx - offset.vx; + renderPos.vy = Pos.vy - offset.vy; + + CRECT collisionRect = getCollisionArea(); + collisionRect.x1 -= Pos.vx; + collisionRect.x2 -= Pos.vx; + collisionRect.y1 -= Pos.vy; + collisionRect.y2 -= Pos.vy; + + if ( renderPos.vx + collisionRect.x2 >= 0 && renderPos.vx + collisionRect.x1 <= VidGetScrW() ) + { + if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= 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); + } + } } \ No newline at end of file diff --git a/source/hazard/hdbarrel.h b/source/hazard/hdbarrel.h index 546bec578..80d1ecfe4 100644 --- a/source/hazard/hdbarrel.h +++ b/source/hazard/hdbarrel.h @@ -22,8 +22,12 @@ class CNpcDualPlatformBarrelHazard : public CNpcHazard { public: void init(); + void render(); protected: void processMovement( int _frames ); + + s16 m_rotation; + s8 m_rotationDir; }; #endif \ No newline at end of file