SBSPSS/source/enemy/npbug.cpp

71 lines
1.4 KiB
C++
Raw Normal View History

2001-04-26 17:13:31 +02:00
/*=========================================================================
npbug.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __ENEMY_NPBUG_H__
#include "enemy\npbug.h"
#endif
#ifndef __LAYER_COLLISION_H__
#include "level\layercollision.h"
#endif
2001-05-29 17:56:44 +02:00
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
2001-05-25 20:43:47 +02:00
#include "game/game.h"
2001-05-29 17:56:44 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-04-26 17:13:31 +02:00
void CNpcPricklyBugEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange )
{
Pos.vx += distX;
Pos.vy += distY;
// sort out draw rotation
DVECTOR testPos1, testPos2;
testPos1 = testPos2 = Pos;
testPos1.vx -= 10;
testPos2.vx += 10;
2001-08-02 16:51:29 +02:00
int groundDist = CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, 16 );
if ( abs( groundDist ) > 15 )
{
m_drawRotation = 0;
return;
}
testPos1.vy += groundDist;
groundDist = CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, 16 );
if ( abs( groundDist ) > 15 )
{
m_drawRotation = 0;
return;
}
testPos2.vy += groundDist;
2001-04-26 17:13:31 +02:00
s32 xDist = testPos2.vx - testPos1.vx;
s32 yDist = testPos2.vy - testPos1.vy;
2001-07-27 15:31:52 +02:00
s16 heading = ratan2( yDist, xDist ) & 4095;
2001-04-26 17:13:31 +02:00
m_drawRotation = heading;
}