Commit 493cecd4 authored by Gerhard Stein's avatar Gerhard Stein

More Physics in Keen Galaxy

parent f49d58ab
......@@ -20,15 +20,25 @@
#include <string.h>
struct ActionFormatType {
int16_t Left_sprite; // 124-400
int16_t Right_sprite; // 124-400
int16_t Movement_parameter; // 0-4
int16_t Change_h; // 0/1
int16_t Change_v; // 0/1
int16_t Delay; // (Anim speed) 0-8000
int16_t H_anim_move_amount; // +- any value
int16_t V_anim_move_amount; // +- any value
enum GalaxyActionType
{
AT_UnscaledOnce = 0, // Unscaled Motion, Thinks once.
AT_ScaledOnce = 1, // Scaled Motion, Thinks once.
AT_Frame = 2, // No Motion, Thinks each frame (doesn't advance action)
AT_UnscaledFrame = 3, // Unscaled Motion, Thinks each frame
AT_ScaledFrame = 4 // Scaled Motion, Thinks each frame
};
struct ActionFormatType
{
int16_t spriteLeft; // 124-400
int16_t spriteRight; // 124-400
int16_t type; // 0-4
int16_t protectAnimation; // 0/1
int16_t stickToGround; // 0/1
int16_t timer; // (Anim speed) 0-8000
int16_t velX; // +- any value
int16_t velY; // +- any value
int16_t Behavior; // [Start of behavior codes only]
int16_t Behavior_segment; // [Segment values only]
int16_t Check_sprites; // [Start of check sprite codes only]
......@@ -37,6 +47,10 @@ struct ActionFormatType {
int16_t Check_segment2; // [Segment values only]
int16_t Next_action; // [Valid actions only]
/*void (*think)(struct CK_object *obj);
void (*collide)(struct CK_object *obj, struct CK_object *other);
void (*draw)(struct CK_object *obj);*/
/**
* \brief set Action Format of the sprite
* \param sprite_offset Offset of the sprite. This is per sprite(object) just one and the same
......
......@@ -113,6 +113,7 @@ class CAudioResources
{
public:
CAudioResources(const SDL_AudioSpec &AudioSpec);
virtual ~CAudioResources() {}
virtual bool loadSoundData() = 0;
virtual void unloadSound() = 0;
......
......@@ -12,8 +12,10 @@ CSpriteObject(pmap, x, y),
mFoeID(foeID),
m_ActionTicker(0),
m_ActionNumber(0),
next(0,0),
m_ActionBaseOffset(0x0),
m_climbing(false),
mClipped(false),
m_jumpdown(false),
mEndOfAction(false)
{}
......@@ -204,9 +206,9 @@ void CGalaxySpriteObject::setAction(size_t ActionNumber)
void CGalaxySpriteObject::setActionSprite()
{
if(m_hDir == LEFT || m_hDir == NONE)
sprite = m_Action.Left_sprite-124;
sprite = m_Action.spriteLeft-124;
else if(m_hDir == RIGHT)
sprite = m_Action.Right_sprite-124;
sprite = m_Action.spriteRight-124;
}
......@@ -229,25 +231,25 @@ bool CGalaxySpriteObject::processActionRoutine()
* 4 is used for sprites that must hit or land on the ground.
*/
if( m_Action.Movement_parameter )
if( m_Action.type > 0 )
{
if(m_hDir == LEFT )
moveLeft( m_Action.H_anim_move_amount<<1 );
moveLeft( m_Action.velX<<1 );
else if(m_hDir == RIGHT )
moveRight( m_Action.H_anim_move_amount<<1 );
moveRight( m_Action.velX<<1 );
if(m_vDir == UP)
moveUp( m_Action.V_anim_move_amount<<1 );
moveUp( m_Action.velY<<1 );
else if(m_vDir == DOWN)
moveDown( m_Action.V_anim_move_amount<<1 );
moveDown( m_Action.velY<<1 );
}
if(mEndOfAction)
return false;
if( m_ActionTicker > m_Action.Delay )
if( m_ActionTicker > m_Action.timer )
{
if( m_Action.Delay != 0 )
if( m_Action.timer != 0 )
{
if(m_Action.Next_action != 0)
m_Action.setNextActionFormat();
......
......@@ -35,9 +35,11 @@ public:
uint16_t mFoeID;
uint16_t m_ActionTicker;
uint16_t m_ActionNumber;
VectorD2<int> next;
size_t m_ActionBaseOffset;
bool m_jumped;
bool m_climbing;
bool mClipped;
bool m_jumpdown;
bool mEndOfAction;
};
......
......@@ -32,13 +32,16 @@ const int POGO_INERTIA_HOR_REACTION = 2;
const int FIRE_RECHARGE_TIME = 5;
const int MAX_POLE_GRAB_TIME = 19;
CPlayerLevel::CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode) :
CPlayerBase(pmap, foeID, x, y, ObjectPtrs, facedir, l_Inventory, Cheatmode),
m_jumpdownfromobject(false),
mPlacingGem(false)
mPlacingGem(false),
mPoleGrabTime(0)
{
mActionMap[A_KEEN_STAND] = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
mActionMap[A_KEEN_LOOKUP] = (void (CPlayerBase::*)()) &CPlayerLevel::processLookingUp;
......@@ -914,6 +917,7 @@ void CPlayerLevel::processPoleClimbing()
setAction(A_KEEN_JUMP);
m_climbing = false;
m_jumped = true;
mPoleGrabTime = 0;
yinertia = 0;
m_vDir = NONE;
solid = true;
......@@ -1028,35 +1032,39 @@ void CPlayerLevel::processPoleClimbing()
bool CPlayerLevel::verifyforPole()
{
// TODO: Something strange here? Ticks?
if ( mPoleGrabTime < MAX_POLE_GRAB_TIME )
return false;
mPoleGrabTime = 0;
Uint32 l_x = ( getXLeftPos() + getXRightPos() ) / 2;
Uint32 l_y_up = ( getYUpPos() );
Uint32 l_y_down = ( getYDownPos() );
l_x = (l_x>>CSF)<<CSF;
const int l_y_up = ( getYUpPos() ) - 192;
const int l_y_down = ( ( getYDownPos() >> CSF ) + 1 ) << CSF;
const int yDir = (m_playcontrol[PA_Y] < 0) ? -1 : 1;
// Now check if Player has the chance to climb a pole or something similar
if( ( m_playcontrol[PA_Y] < 0 && hitdetectWithTileProperty(1, l_x, l_y_up) ) ||
( m_playcontrol[PA_Y] > 0 && hitdetectWithTileProperty(1, l_x, l_y_down) ) ) // 1 -> stands for pole Property
{
// Hit pole!
// calc the proper coord of that tile
l_x = (l_x>>CSF)<<CSF;
if( ( m_playcontrol[PA_Y] < 0 && hitdetectWithTileProperty(1, l_x, l_y_up) ) ||
( m_playcontrol[PA_Y] > 0 && hitdetectWithTileProperty(1, l_x, l_y_down) ) )
{
// Move to the proper X Coordinates, so Keen really grabs it!
moveTo(VectorD2<int>(l_x - (7<<STC), getYPosition()));
xinertia = 0;
if( ( yDir < 0 && ( hitdetectWithTileProperty(1, l_x, l_y_up) & 0x7F) == 1 ) ||
( yDir > 0 && ( hitdetectWithTileProperty(1, l_x, l_y_down) & 0x7F) == 1 ) ) // 1 -> stands for pole Property
{
// Move to the proper X Coordinates, so Keen really grabs it!
moveTo(VectorD2<int>(l_x - (7<<STC), getYPosition()));
// Set Keen in climb mode
setAction(A_KEEN_POLE);
m_climbing = true;
solid = false;
return true;
}
xinertia = 0;
next.x = 0;
next.y = 64*yDir;
// Set Keen in climb mode
setAction(A_KEEN_POLE);
m_climbing = true;
mClipped = false;
solid = false;
return true;
}
return false;
}
......@@ -1395,6 +1403,9 @@ void CPlayerLevel::process()
}
}
if ( mPoleGrabTime < MAX_POLE_GRAB_TIME )
mPoleGrabTime++;
(this->*mp_processState)();
// make the fire recharge time decreased if player is not pressing firing button
......
......@@ -26,7 +26,6 @@ A_KEEN_LOOKDOWN = 23,
A_KEEN_ACTION_1 = 26,
A_KEEN_ACTION_2 = 27,
A_KEEN_ACTION_3 = 28,
//A_KEEN_DIE = 29 // defined in CPlayerBase
A_KEEN_SHOOT = 33,
A_KEEN_SHOOT_UP = 35,
A_KEEN_ACTION_4 = 37,
......@@ -53,7 +52,8 @@ A_KEEN_CLIMB = 82
};
class CPlayerLevel : public CPlayerBase {
class CPlayerLevel : public CPlayerBase
{
public:
CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< SmartPointer<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
......@@ -249,6 +249,7 @@ private:
int m_fire_recharge_time;
bool m_EnterDoorAttempt;
bool m_hanging;
int mPoleGrabTime;
};
}
......
......@@ -47,7 +47,7 @@ void CCouncilMember::processWalking()
// Check if there is a cliff and move him back in case
performCliffStop(m_Action.H_anim_move_amount<<1);
performCliffStop(m_Action.velX<<1);
if( m_timer < ELDER_MOVE_TIMER )
......@@ -71,9 +71,9 @@ void CCouncilMember::processWalking()
// Move normally in the direction
if( m_hDir == RIGHT )
moveRight( m_Action.H_anim_move_amount<<1 );
moveRight( m_Action.velX<<1 );
else
moveLeft( m_Action.H_anim_move_amount<<1 );
moveLeft( m_Action.velX<<1 );
}
......
......@@ -52,7 +52,7 @@ void CPoisonSlug::processCrawling()
// Check if there is a cliff
performCliffStop(m_Action.H_anim_move_amount<<1);
performCliffStop(m_Action.velX<<1);
if( m_timer < SLUG_MOVE_TIMER )
......@@ -77,9 +77,9 @@ void CPoisonSlug::processCrawling()
// Move normally in the direction
if( m_hDir == RIGHT )
moveRight( m_Action.H_anim_move_amount<<1 );
moveRight( m_Action.velX<<1 );
else
moveLeft( m_Action.H_anim_move_amount<<1 );
moveLeft( m_Action.velX<<1 );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment