Commit e6c27d38 authored by Gerstrong's avatar Gerstrong

Camera class has a member function that check for attached objects which got...

Camera class has a member function that check for attached objects which got outside and Keen now correctly dies in the Galaxy Engine
parent e0fd8b04
......@@ -154,3 +154,23 @@ void CCamera::process(const bool force)
while(scroll_y > mp_Map->m_maxscrolly)
mp_Map->scrollUp(true);
}
bool CCamera::outOfSight()
{
bool outofsight = false;
const int cam_width = ((g_pVideoDriver->getGameResolution().w/2)<<STC);
const int cam_height = ((g_pVideoDriver->getGameResolution().h/2)<<STC);
if( mp_AttachedObject->getXLeftPos() > getXPosition() + cam_width )
outofsight |= true;
else if( mp_AttachedObject->getXRightPos() < getXPosition() - cam_width )
outofsight |= true;
if( mp_AttachedObject->getYUpPos() > getYPosition() + cam_height )
outofsight |= true;
else if( mp_AttachedObject->getYDownPos() < getYPosition() - cam_height )
outofsight |= true;
return outofsight;
}
......@@ -48,6 +48,15 @@ public:
* \param force If on the map are scrollblockers, they will be ignored when this is enabled
*/
void process(const bool force = false);
/**
* \brief
* This function tells if the attached object is out of the camera view
*
* \return true if the Attached object is outside the camera, else false
*/
bool outOfSight();
bool m_attached;
bool m_freeze;
......
......@@ -16,7 +16,6 @@
namespace galaxy {
const int MAX_JUMPHEIGHT = 10;
const int MIN_JUMPHEIGHT = 5;
......@@ -983,18 +982,36 @@ void CPlayerLevel::processPlaceGem()
}
void CPlayerLevel::processDead()
{
m_Inventory.Item.m_lifes--;
setActionForce(A_KEEN_DIE);
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), false) );
m_dying = false;
}
const int DIE_FALL_SPEED = 7;
const int DIE_FALL_MAX_INERTIA = 150;
const int DIE_RIGHT_INERTIA = 40;
void CPlayerLevel::processDying()
{
// TODO: Here Keen must be falling out the screen, die effect of Keen Galaxy
m_Inventory.Item.m_lifes--;
setActionForce(A_KEEN_DIE);
g_pSound->playSound( SOUND_KEEN_DIE );
moveYDir(yinertia);
moveRight(DIE_RIGHT_INERTIA);
yinertia += DIE_FALL_SPEED;
if( m_camera.outOfSight() )
{
mp_processState = &CPlayerLevel::processDead;
solid = true;
honorPriority = true;
}
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventExitLevel(mp_Map->getLevel(), false) );
}
void CPlayerLevel::kill()
......@@ -1002,7 +1019,18 @@ void CPlayerLevel::kill()
// TODO: Here were prepare Keen to die, setting that action
// We still need that animation when he really dies.
if(!m_Cheatmode.god)
{
if(mp_processState == &CPlayerLevel::processDying && yinertia < 0)
return;
m_dying = true;
yinertia = -DIE_FALL_MAX_INERTIA;
setAction( A_KEEN_DIE + (rand()%2) );
solid = false;
honorPriority = false;
g_pSound->playSound( SOUND_KEEN_DIE, PLAY_NORESTART );
mp_processState = &CPlayerLevel::processDying;
}
}
......@@ -1474,41 +1502,38 @@ void CPlayerLevel::processFalling()
void CPlayerLevel::process()
{
if(m_dying)
if(!m_dying)
{
processDying();
return;
}
processInput();
processInput();
// If no clipping was triggered change solid state of keen
if(m_Cheatmode.noclipping)
{
solid = !solid;
m_Cheatmode.noclipping = false;
}
// If no clipping was triggered change solid state of keen
if(m_Cheatmode.noclipping)
{
solid = !solid;
m_Cheatmode.noclipping = false;
if(supportedbyobject)
blockedd = true;
}
if(supportedbyobject)
blockedd = true;
(this->*mp_processState)();
processLevelMiscFlagsCheck();
processActionRoutine();
if(!m_dying)
{
processExiting();
}
processActionRoutine();
m_camera.process();
m_camera.processEvents();
m_camera.process();
m_camera.processEvents();
performCollisions();
performCollisions();
processPushOutCollision();
processPushOutCollision();
}
}
......
......@@ -218,6 +218,7 @@ public:
void openDoorsTile();
void processPlaceGem();
void processDead();
void processDying();
void kill();
......
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