Commit eb1f0354 authored by Gerhard Stein's avatar Gerhard Stein

introduced extra variable for vertical directions. Sadly we need to separate...

introduced extra variable for vertical directions. Sadly we need to separate them in order to combine action format and galaxy engine.
parent f0b6779f
......@@ -55,7 +55,7 @@ m_Pos(x,y)
cansupportplayer = false;
dying = false;
m_ActionBaseOffset = 0x0;
m_direction = NONE;
m_vDir = m_hDir = NONE;
m_ActionTicker = 0;
m_canturnaround = false;
m_climbing = false;
......@@ -199,7 +199,6 @@ bool CObject::checkforScenario()
return false;
}
// Used in some setup mode, like putting the player to
// the current map position
void CObject::moveToForce(const VectorD2<int> &dir)
......@@ -485,7 +484,7 @@ void CObject::processFalling()
if(m_type == OBJ_MESSIE) return;
// So it reaches the maximum of fallspeed
if(!inhibitfall)
if(!inhibitfall && !m_climbing)
{
CPhysicsSettings &Physics = g_pBehaviorEngine->getPhysicsSettings();
......@@ -607,22 +606,30 @@ void CObject::setAction(size_t ActionNumber)
// This new function will setup the sprite based on the Action format
void CObject::processActionRoutine()
{
if(m_direction == LEFT)
if(m_hDir == LEFT)
sprite = m_Action.Left_sprite-124;
else if(m_direction == RIGHT)
else if(m_hDir == RIGHT)
sprite = m_Action.Right_sprite-124;
//printf("h=%d ; v=%d no=%d\n", m_Action.Change_h, m_Action.Change_v);
//printf("h_move=%d ; v_move=%d\n", m_Action.H_anim_move_amount, m_Action.V_anim_move_amount);
if(m_hDir == LEFT)
moveLeft( m_Action.H_anim_move_amount<<1 );
else if(m_hDir == RIGHT)
moveRight( m_Action.H_anim_move_amount<<1 );
if(m_vDir == UP)
moveUp( m_Action.V_anim_move_amount<<1 );
else if(m_vDir == DOWN)
moveDown( m_Action.V_anim_move_amount<<1 );
if( m_ActionTicker > m_Action.Delay )
{
if( m_Action.Delay != 0 && m_Action.Next_action != 0 )
{
m_Action.setNextActionFormat();
/*printf("h=%d ; v=%d\n", m_Action.Change_h, m_Action.Change_v);
printf("h_move=%d ; v_move=%d\n", m_Action.H_anim_move_amount, m_Action.V_anim_move_amount);
if(m_Action.Change_h)
moveXDir( m_Action.H_anim_move_amount );
if(m_Action.Change_v)
moveYDir( m_Action.V_anim_move_amount );*/
}
m_ActionTicker = 0;
}
......
......@@ -55,8 +55,10 @@ public:
bool exists;
bool onscreen; // true=(scrx,scry) position is visible onscreen
bool hasbeenonscreen;
unsigned int sprite; // which sprite should this object be drawn with
direction_t m_direction; // the direction to where the object is looking/heading to
unsigned int sprite; // which sprite should this object be drawn with
direction_t m_hDir; // the direction to where the object is looking/heading to
direction_t m_vDir; // same for vertical
int scrx, scry; // x,y pixel position on screen
// Bouncing Boxes
......@@ -108,7 +110,7 @@ public:
void setScrPos( int px, int py );
bool calcVisibility();
bool checkforScenario();
// Moving parts
void moveToForce(const VectorD2<int> &dir);
void moveToForce(int new_x, int new_y);
......@@ -138,7 +140,6 @@ public:
bool checkSolidU( int x1, int x2, int y1);
bool checkSolidD( int x1, int x2, int y2);
// special functions for sloped tiles
bool checkslopedU( int c, int y1, char blocked);
bool checkslopedD( int c, int y2, char blocked);
......
......@@ -29,7 +29,7 @@ m_ObjectPtrs(ObjectPtrs),
m_cliff_hanging(false)
{
m_index = 0;
m_direction = facedir;
m_hDir = facedir;
m_ActionBaseOffset = 0x98C;
setActionForce(A_KEEN_STAND);
......@@ -74,13 +74,10 @@ void CPlayerLevel::process()
processExiting();
processActionRoutine();
moveXDir(xinertia);
xinertia = 0;
if(m_climbing)
moveYDir(yinertia);
processActionRoutine();
}
void CPlayerLevel::processInput()
......@@ -179,41 +176,26 @@ void CPlayerLevel::processFiring()
}
void CPlayerLevel::processFalling()
{
if(m_climbing || m_cliff_hanging) return;
CObject::processFalling();
if( falling && !getActionNumber(A_KEEN_JUMP_SHOOT)
&& !getActionNumber(A_KEEN_JUMP_SHOOTUP) && !getActionNumber(A_KEEN_JUMP_SHOOTDOWN) )
setAction(A_KEEN_FALL);
}
void CPlayerLevel::processMoving()
{
size_t movespeed = 50;
direction_t moving = NONE;
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
if(m_cliff_hanging)
{
if(m_playcontrol[PA_Y] < 0)
{
//m_cliff_hanging = false;
if(!getActionNumber(A_KEEN_CLIMB))
setAction(A_KEEN_CLIMB);
setAction(A_KEEN_CLIMB);
}
else if(m_playcontrol[PA_Y] > 0)
{
m_cliff_hanging = false;
if(!getActionNumber(A_KEEN_FALL))
setAction(A_KEEN_FALL);
setAction(A_KEEN_FALL);
}
yinertia = 0;
}
else
{
if(m_climbing)
{
// The climbing section for Keen
......@@ -222,21 +204,18 @@ void CPlayerLevel::processMoving()
Uint16 l_y_down = getYDownPos()-(7<<STC);
if(m_playcontrol[PA_Y] < 0 && hitdetectWithTileProperty(1, l_x, l_y_up) )
{
if(!getActionNumber(A_KEEN_POLE_CLIMB))
setAction(A_KEEN_POLE_CLIMB);
yinertia = -32;
setAction(A_KEEN_POLE_CLIMB);
m_vDir = UP;
}
else if(m_playcontrol[PA_Y] > 0 && hitdetectWithTileProperty(1, l_x, l_y_down) )
{
if(!getActionNumber(A_KEEN_POLE_SLIDE))
setAction(A_KEEN_POLE_SLIDE);
yinertia = 64;
setAction(A_KEEN_POLE_SLIDE);
m_vDir = DOWN;
}
else // == 0
{
if(!getActionNumber(A_KEEN_POLE))
setAction(A_KEEN_POLE);
yinertia = 0;
setAction(A_KEEN_POLE);
m_vDir = NONE;
}
}
else
......@@ -248,9 +227,8 @@ void CPlayerLevel::processMoving()
{
if(!blockedl)
{
// make him walk
xinertia = -movespeed;
m_direction = LEFT;
// prepare him to walk
moving = m_hDir = LEFT;
}
else
{
......@@ -272,8 +250,8 @@ void CPlayerLevel::processMoving()
{
if(!blockedr)
{
xinertia = movespeed;
m_direction = RIGHT;
// prepare him to walk
moving = m_hDir = RIGHT;
}
else
{
......@@ -316,7 +294,7 @@ void CPlayerLevel::processMoving()
if( blockedd )
{
if(xinertia != 0)
if(moving != NONE)
setAction(A_KEEN_RUN);
else if(m_playcontrol[PA_Y] == 0)
setAction(A_KEEN_STAND);
......@@ -371,9 +349,27 @@ void CPlayerLevel::processJumping()
yinertia = 0;
m_jumpheight = 0;
}
xinertia += (m_playcontrol[PA_X]>>1);
}
}
// Falling code
void CPlayerLevel::processFalling()
{
if(m_climbing || m_cliff_hanging) return;
CObject::processFalling();
if( falling && !getActionNumber(A_KEEN_JUMP_SHOOT)
&& !getActionNumber(A_KEEN_JUMP_SHOOTUP) && !getActionNumber(A_KEEN_JUMP_SHOOTDOWN) )
setAction(A_KEEN_FALL);
if(getActionNumber(A_KEEN_FALL))
xinertia += (m_playcontrol[PA_X]>>1);
}
// This is for processing the looking routine.
void CPlayerLevel::processLooking()
{
......@@ -381,15 +377,12 @@ void CPlayerLevel::processLooking()
return;
// Looking Up and Down Routine
//bool notshooting = ;
if(blockedd && xinertia == 0 /*&& notshooting*/)
if(blockedd && xinertia == 0 )
{
if( m_playcontrol[PA_Y]<0 )
setAction(A_KEEN_LOOKUP);
else if( m_playcontrol[PA_Y]>0 )
setAction(A_KEEN_LOOKDOWN);
//else
//setAction(A_KEEN_STAND);
}
}
......
......@@ -21,9 +21,9 @@ void nessie_find_next_checkpoint(int o);
CMessie::CMessie(CMap *p_map, Uint32 x, Uint32 y,
std::vector<CPlayer>& Player) :
CObject(p_map, x, y, OBJ_MESSIE),
m_direction(LEFTDOWN),
m_Player(Player)
{
m_hDir = LEFTDOWN;
onscreen = true;
solid = false;
......@@ -109,13 +109,13 @@ void CMessie::process()
bool godown = (desty > getYPosition());
if(goleft && !godown)
m_direction = LEFTUP;
m_hDir = LEFTUP;
else if(goleft && godown)
m_direction = LEFTDOWN;
m_hDir = LEFTDOWN;
else if(!goleft && !godown)
m_direction = RIGHTUP;
m_hDir = RIGHTUP;
else if(!goleft && godown)
m_direction = RIGHTDOWN;
m_hDir = RIGHTDOWN;
}
}
move_nessie();
......@@ -137,13 +137,13 @@ void CMessie::process()
void CMessie::move_nessie()
{
// select proper frame based on up/down and left/right direction flags
if (m_direction == LEFTDOWN)
if (m_hDir == LEFTDOWN)
baseframe = NESSIE_DOWNLEFT_FRAME;
else if (m_direction == RIGHTDOWN)
else if (m_hDir == RIGHTDOWN)
baseframe = NESSIE_DOWNRIGHT_FRAME;
else if (m_direction == LEFTUP)
else if (m_hDir == LEFTUP)
baseframe = NESSIE_UPLEFT_FRAME;
else if (m_direction == RIGHTUP)
else if (m_hDir == RIGHTUP)
baseframe = NESSIE_UPRIGHT_FRAME;
// head to destination
......
......@@ -8,8 +8,8 @@
#ifndef CMESSIE_H_
#define CMESSIE_H_
#include "../../../common/CObject.h"
#include "../../../common/CPlayer.h"
#include "common/CObject.h"
#include "common/CPlayer.h"
#define NESSIETRAILLEN 5
......@@ -24,7 +24,6 @@ public:
//private:
char state;
direction_t m_direction;
unsigned int baseframe;
......
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