Commit c2d4d774 authored by Gerhard Stein's avatar Gerhard Stein

keen learns to swim on map :-). There are still collision problems. I think...

keen learns to swim on map :-). There are still collision problems. I think it's sprite related. need to check out that further
parent f30ca60e
......@@ -9,6 +9,9 @@
#include "../../../common/CBehaviorEngine.h"
#include "../../../sdl/CInput.h"
const Uint16 WALKBASEFRAME = 130;
const Uint16 SWIMBASEFRAME = 156;
namespace galaxy {
CPlayerWM::CPlayerWM(CMap *pmap, Uint32 x, Uint32 y):
......@@ -101,12 +104,14 @@ void CPlayerWM::processWalking()
g_pInput->flushCommands();
}
performWalkingAnimation(walking);
// this means if keen is just walking on the map or swimming in the sea
if(m_basesprite == WALKBASEFRAME)
performWalkingAnimation(walking);
else if(m_basesprite == SWIMBASEFRAME)
performSwimmingAnimation();
// This will trigger between swim and walkmode
checkforSwimming();
}
......@@ -128,6 +133,49 @@ void CPlayerWM::finishlevel(Uint16 object)
// TODO: spawn the flag that will be spawn
}
/**
* This is the function will switch between swim and walk mode
* Those are the tileproperties to check for
* 11 Enter water from top Keen 4
* 12 Enter water from right Keen 4
* 13 Enter water from bottom Keen 4
* 14 Enter water from left Keen 4
*/
void CPlayerWM::checkforSwimming()
{
Uint16 left, right, up, down;
std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
left = Tile[mp_Map->at( getXLeftPos()>>CSF, getYMidPos()>>CSF, 1)].behaviour;
right = Tile[mp_Map->at( getXRightPos()>>CSF, getYMidPos()>>CSF, 1)].behaviour;
up = Tile[mp_Map->at( getXMidPos()>>CSF, getYUpPos()>>CSF, 1)].behaviour;
down = Tile[mp_Map->at( getXMidPos()>>CSF, getYDownPos()>>CSF, 1)].behaviour;
// from top
if(up == 11)
m_basesprite = SWIMBASEFRAME;
else if(down == 11)
m_basesprite = WALKBASEFRAME;
// from right
if(right == 12)
m_basesprite = SWIMBASEFRAME;
else if(left == 12)
m_basesprite = WALKBASEFRAME;
// from bottom
if(down == 13)
m_basesprite = SWIMBASEFRAME;
else if(up == 13)
m_basesprite = WALKBASEFRAME;
// from left
if(left == 14)
m_basesprite = SWIMBASEFRAME;
else if(right == 14)
m_basesprite = WALKBASEFRAME;
}
/**
* This performs the animation when player is walking on the map
*/
......@@ -153,12 +201,35 @@ void CPlayerWM::performWalkingAnimation(bool walking)
if(walking)
{
m_animation_time = 5;
sprite += m_animation%2;
sprite += m_animation%3;
}
else
sprite += 2;
}
void CPlayerWM::performSwimmingAnimation()
{
if(m_looking_dir == UP)
sprite = m_basesprite;
else if(m_looking_dir == RIGHT)
sprite = m_basesprite + 2;
else if(m_looking_dir == DOWN)
sprite = m_basesprite + 4;
else if(m_looking_dir == LEFT)
sprite = m_basesprite + 6;
else if(m_looking_dir == RIGHTUP)
sprite = m_basesprite + 8;
else if(m_looking_dir == RIGHTDOWN)
sprite = m_basesprite + 10;
else if(m_looking_dir == LEFTDOWN)
sprite = m_basesprite + 12;
else if(m_looking_dir == LEFTUP)
sprite = m_basesprite + 14;
m_animation_time = 5;
sprite += m_animation%2;
}
CPlayerWM::~CPlayerWM() {
// TODO Auto-generated destructor stub
}
......
......@@ -19,8 +19,10 @@ public:
void processWalking();
void finishlevel(Uint16 object);
void checkforSwimming();
void performWalkingAnimation(bool walking);
void performSwimmingAnimation();
virtual ~CPlayerWM();
private:
......
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