This commit is contained in:
parent
8039b5a767
commit
a18f4ae7bb
2 changed files with 119 additions and 0 deletions
82
source/hazard/hmasher.cpp
Normal file
82
source/hazard/hmasher.cpp
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
hmasher.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HMASHER_H__
|
||||||
|
#include "hazard\hmasher.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __LAYER_COLLISION_H__
|
||||||
|
#include "level\layercollision.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void CNpcMasherHazard::init()
|
||||||
|
{
|
||||||
|
CNpcHazard::init();
|
||||||
|
|
||||||
|
m_state = MASHER_DROPPING;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CNpcMasherHazard::processMovement( int _frames )
|
||||||
|
{
|
||||||
|
switch ( m_state )
|
||||||
|
{
|
||||||
|
case MASHER_DROPPING:
|
||||||
|
{
|
||||||
|
s8 yMovement = 3 * _frames;
|
||||||
|
|
||||||
|
s8 groundHeight;
|
||||||
|
|
||||||
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight < yMovement )
|
||||||
|
{
|
||||||
|
// colliding with ground
|
||||||
|
|
||||||
|
Pos.vy += groundHeight;
|
||||||
|
|
||||||
|
// pause and change direction
|
||||||
|
|
||||||
|
m_state = MASHER_RISING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// drop down
|
||||||
|
|
||||||
|
Pos.vy += yMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MASHER_RISING:
|
||||||
|
{
|
||||||
|
if ( m_base.vx - Pos.vx == 0 && m_base.vy - Pos.vy == 0 )
|
||||||
|
{
|
||||||
|
m_state = MASHER_DROPPING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// return to original position
|
||||||
|
|
||||||
|
Pos.vy -= 3 * _frames;
|
||||||
|
|
||||||
|
if ( Pos.vy < m_base.vy )
|
||||||
|
{
|
||||||
|
Pos.vy = m_base.vy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
source/hazard/hmasher.h
Normal file
37
source/hazard/hmasher.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
hmasher.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HMASHER_H__
|
||||||
|
#define __HAZARD_HMASHER_H__
|
||||||
|
|
||||||
|
#ifndef __HAZARD_HAZARD_H__
|
||||||
|
#include "hazard\hazard.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcMasherHazard : public CNpcHazard
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void init();
|
||||||
|
protected:
|
||||||
|
void processMovement( int _frames );
|
||||||
|
|
||||||
|
enum MASHER_STATE
|
||||||
|
{
|
||||||
|
MASHER_DROPPING,
|
||||||
|
MASHER_RISING,
|
||||||
|
};
|
||||||
|
|
||||||
|
MASHER_STATE m_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue