Commit 2e5960cf authored by Gerhard Stein's avatar Gerhard Stein

Teleporter Code

parent 9bc01e5a
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -274,18 +274,7 @@ void CPlayGameGalaxy::process()
{
if( EventEnterLevel *ev = eventContainer.occurredEvent<EventEnterLevel>() )
{
// In Keen 5, 6 there teleporters
if(ev->data < 0xC000 && ev->data > 0x100)
{
g_pLogFile->ftextOut("Teleporters/Elevators not yet implemented!");
const Uint32 filter = ev->data & 0xFFFF;
const Uint32 newPosX = (filter & 0xFF00) >> 8;
const Uint32 newPosY = (filter & 0x00FF);
g_pLogFile->ftextOut("Pos would be (%d, %d)", newPosX, newPosY);
}
else // Start a new level!
if(ev->data >= 0xC000) // Start a new level!
{
const Uint16 NewLevel = ev->data - 0xC000;
if(NewLevel < 50)
......
......@@ -47,6 +47,8 @@ m_cantswim(false)
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
mProcessPtr = &CPlayerWM::processMoving;
}
/**
......@@ -62,7 +64,8 @@ void CPlayerWM::process()
}
else m_animation_ticker++;
processMoving();
//processMoving();
(this->*mProcessPtr)();
// Events for the Player are processed here.
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
......@@ -102,6 +105,10 @@ void CPlayerWM::processMoving()
// This will trigger between swim and walkmode
checkforSwimming(bleft, bright, bup, bdown);
// In Episode 5 and 5 there are teleporters. Verify those teleporters and elevators
if(g_pBehaviorEngine->getEpisode() >= 5)
verifyTeleportation();
// Normal walking
if(g_pInput->getHoldedCommand(IC_LEFT) && !bleft)
{
......@@ -190,6 +197,69 @@ void CPlayerWM::processMoving()
}
}
void CPlayerWM::verifyTeleportation()
{
//target -> change it when the touched tile is known
const int x = getXMidPos();
const int y = getYUpPos();
// Check if Keen touches a teleporter or elevator
const Uint16 object = mp_Map->getPlaneDataAt( 2, x, y );
if(object < 0xC000 && object > 0x100)
{
//const Uint32 filter = object & 0xFFFF;
//const Uint32 newPosX = (filter & 0xFF00) >> 8;
//const Uint32 newPosY = (filter & 0x00FF);
target.x = ( x >> CSF ) << CSF;
target.y = ( y >> CSF ) << CSF;
bool isElevator = false;
// Elevator are double the size. Check that! Else it must be an teleporter
if(object == mp_Map->getPlaneDataAt( 2, x - (1<<CSF), y ))
isElevator |= true;
if(object == mp_Map->getPlaneDataAt( 2, x + (1<<CSF), y ))
isElevator |= true;
if(isElevator)
mProcessPtr = &CPlayerWM::processEnteringElevator;
else
mProcessPtr = &CPlayerWM::processEnteringTeleporter;
}
// TODO: In that case get the tile where to go and make him move or
// TODO: In that case get the tile where to move and make him move until teleporter hides him
}
void CPlayerWM::processEnteringElevator()
{
performWalkingAnimation(true);
}
void CPlayerWM::processClosingElevator()
{}
void CPlayerWM::processElevating()
{}
void CPlayerWM::processOpeningElevator()
{}
void CPlayerWM::processLeavingElevator()
{}
void CPlayerWM::processEnteringTeleporter()
{}
/**
* This function will help starting the level for Commander Keen
*/
......
......@@ -27,6 +27,16 @@ public:
void process();
void processMoving();
// Episode 5 and 6: Those processes make Keen walk through elevators and teleporters
void verifyTeleportation();
void processEnteringElevator();
void processClosingElevator();
void processElevating();
void processOpeningElevator();
void processLeavingElevator();
void processEnteringTeleporter();
void startLevel(Uint16 object);
void finishLevel(Uint16 object);
void checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdown);
......@@ -44,6 +54,9 @@ private:
Uint8 m_animation_time;
Uint8 m_animation_ticker;
bool m_cantswim;
VectorD2<int> target;
void (CPlayerWM::*mProcessPtr)();
};
}
......
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