Commit a4ef606e authored by Gerhard Stein's avatar Gerhard Stein

More Stuff doing with the foot, but code still incomplete

parent 7cbf5de8
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,7 +13,7 @@ Porting:
Released under GNU/GPL
Release v0.4.0-Beta4
Build: DINGOO
Build:
**********************************************
Welcome to Commander Genius!
......
......@@ -46,6 +46,12 @@ struct EventExitLevel : CEvent {
EventExitLevel(const uint16_t l, const bool s) : levelObject(l), sucess(s){}
};
struct EventExitLevelWithFoot : CEvent {
const uint16_t levelObject;
EventExitLevelWithFoot(const uint16_t l) : levelObject(l) {}
};
struct EventRestartLevel : CEvent {
};
......@@ -58,6 +64,12 @@ struct EventPlayerEndLevel : CEvent {
levelObject(ev.levelObject), sucess(ev.sucess) {}
};
struct EventPlayerRideFoot : CEvent {
const uint16_t levelObject;
EventPlayerRideFoot(const EventExitLevelWithFoot ev) :
levelObject(ev.levelObject) {}
};
struct EventPlayTrack : CEvent {
const uint32_t track;
......
......@@ -305,6 +305,16 @@ void CPlayGameGalaxy::process()
eventContainer.add( new EventPlayerEndLevel(*ev) );
eventContainer.pop_Event();
}
else if( EventExitLevelWithFoot *ev = eventContainer.occurredEvent<EventExitLevelWithFoot>() )
{
g_pMusicPlayer->stop();
m_LevelPlay.setActive(false);
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
eventContainer.add( new EventPlayerRideFoot(*ev) );
eventContainer.pop_Event();
}
else if( EventPlayTrack *ev = eventContainer.occurredEvent<EventPlayTrack>() )
{
g_pMusicPlayer->stop();
......
......@@ -14,6 +14,8 @@
#include "sdl/sound/CSound.h"
#include "CVec.h"
const int A_KEEN_RIDING_ON_FOOT = 94;
namespace galaxy {
CPlayerWM::CPlayerWM(CMap *pmap,
......@@ -80,6 +82,20 @@ void CPlayerWM::process()
EventContainer.pop_Event();
}
if( EventPlayerRideFoot* ev = EventContainer.occurredEvent<EventPlayerRideFoot>() )
{
finishLevel(ev->levelObject);
solid = false;
// TODO: Here we need to set the coordinates calculated to where Keen has to go.
// target = ?
setAction(A_KEEN_RIDING_ON_FOOT);
mProcessPtr = &CPlayerWM::processRiding;
}
m_camera.process();
m_camera.processEvents();
}
......@@ -197,6 +213,39 @@ void CPlayerWM::processMoving()
}
}
const int RIDE_SPEED = 32;
void CPlayerWM::processRiding()
{
// Ride while trying to reach the destination coords
// Move the player to the target
VectorD2<int> pos(getXPosition(), getYPosition());
VectorD2<int> vec = target-pos;
VectorD2<int> vec_norm = vec;
const int dist_x = abs(vec.x);
const int dist_y = abs(vec.y);
if(dist_x != 0)
vec_norm.x = vec.x/dist_x;
if(dist_y != 0)
vec_norm.y = vec.y/dist_y;
if( dist_x < RIDE_SPEED && dist_y < RIDE_SPEED)
{
// When he reaches the target. make him visible and start opening the elevator
moveDir(vec);
setAction(0);
mProcessPtr = &CPlayerWM::processMoving;
solid = true;
}
else
{
moveDir(vec_norm*RIDE_SPEED);
}
}
void CPlayerWM::verifyTeleportation()
{
......
......@@ -27,6 +27,9 @@ public:
void process();
void processMoving();
// Episode 4 only. When Keen is riding on the foot
void processRiding();
// Episode 5 and 6: Those processes make Keen walk through elevators and teleporters
void verifyTeleportation();
void processEnteringElevator();
......
......@@ -13,7 +13,7 @@ CFoot::CFoot(CMap *pmap, const Uint16 foeID, const Uint32 x, const Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y)
{
// TODO Auto-generated constructor stub
}
} /* namespace galaxy */
......@@ -60,14 +60,14 @@ bool CInchWorm::isNearby(CSpriteObject &theObject)
mInchWormContacts++;
}
/*if(mInchWormContacts >= 11)
if(mInchWormContacts >= 11)
{
if(!g_pBehaviorEngine->m_EventList.find<CFoot>()) // if you find the event in the queue don't create another.
/*if(!g_pBehaviorEngine->m_EventList.find<CFoot>()) // if you find the event in the queue don't create another.
{
CFoot *foot = new CFoot( getMapPtr(), getXMidPos(), getYUpPos()-(3<<CSF), RIGHT );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( foot ) );
}
}*/
}*/
}
}
return true;
......
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