This commit is contained in:
parent
4f29aca643
commit
6d7237fbc7
2 changed files with 86 additions and 0 deletions
|
@ -19,14 +19,30 @@
|
||||||
#include "level\layercollision.h"
|
#include "level\layercollision.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __VID_HEADER_
|
||||||
|
#include "system\vid.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __LEVEL_LEVEL_H__
|
||||||
|
#include "level\level.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcBouncingBarrelHazard::init()
|
void CNpcBouncingBarrelHazard::init()
|
||||||
{
|
{
|
||||||
CNpcHazard::init();
|
CNpcHazard::init();
|
||||||
|
|
||||||
m_lastWaypoint = Pos;
|
m_lastWaypoint = Pos;
|
||||||
|
|
||||||
|
m_rotation = 0;
|
||||||
|
m_rockRotation = 0;
|
||||||
|
m_rockDir = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||||
{
|
{
|
||||||
s32 moveX = 0, moveY = 0;
|
s32 moveX = 0, moveY = 0;
|
||||||
|
@ -53,9 +69,36 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||||
}
|
}
|
||||||
|
|
||||||
moveX = 3 * _frames;
|
moveX = 3 * _frames;
|
||||||
|
|
||||||
if ( waypointHeading == 2048 )
|
if ( waypointHeading == 2048 )
|
||||||
{
|
{
|
||||||
moveX = -moveX;
|
moveX = -moveX;
|
||||||
|
m_rotation -= 256 * _frames;
|
||||||
|
m_rotation &= 4095;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_rotation += 256 * _frames;
|
||||||
|
m_rotation &= 4095;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_rockDir )
|
||||||
|
{
|
||||||
|
m_rockRotation += 30 * _frames;
|
||||||
|
|
||||||
|
if ( m_rockRotation > 256 )
|
||||||
|
{
|
||||||
|
m_rockDir = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_rockRotation -= 30 * _frames;
|
||||||
|
|
||||||
|
if ( m_rockRotation < -256 )
|
||||||
|
{
|
||||||
|
m_rockDir = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Pos.vx += moveX;
|
Pos.vx += moveX;
|
||||||
|
@ -80,3 +123,41 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames )
|
||||||
Pos.vy = m_lastWaypoint.vy - ( ( abs( nextWaypoint.vy - m_lastWaypoint.vy ) * rsin( sineVal ) ) >> 12 );
|
Pos.vy = m_lastWaypoint.vy - ( ( abs( nextWaypoint.vy - m_lastWaypoint.vy ) * rsin( sineVal ) ) >> 12 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcBouncingBarrelHazard::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 = m_rockRotation;
|
||||||
|
rotation.vy = 0;
|
||||||
|
rotation.vz = m_rotation;
|
||||||
|
|
||||||
|
VECTOR scale;
|
||||||
|
scale.vx = ONE;
|
||||||
|
scale.vy = ONE;
|
||||||
|
scale.vz = ONE;
|
||||||
|
|
||||||
|
m_modelGfx->Render(renderPos,&rotation,&scale);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,10 +22,15 @@ class CNpcBouncingBarrelHazard : public CNpcHazard
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
|
void render();
|
||||||
protected:
|
protected:
|
||||||
void processMovement( int _frames );
|
void processMovement( int _frames );
|
||||||
|
|
||||||
DVECTOR m_lastWaypoint;
|
DVECTOR m_lastWaypoint;
|
||||||
|
|
||||||
|
s16 m_rotation;
|
||||||
|
s16 m_rockRotation;
|
||||||
|
u8 m_rockDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Add table
Reference in a new issue