Commit 91c15cad authored by Gerhard Stein's avatar Gerhard Stein

Bug fixes with the platforms when using more players

parent 57ab9002
v1.5 Release:
v1.6 Release:
---------------
- XML based Savegame states in both galaxy and vorticon engine which in future
will make those savegames more robust, when coming from older or newer versions.
This means hopefully, no more crashes in savegames.
- Up to four Players in Galaxy, with everyone having it's HUD
- The HUD are now a bit translucent by default
- Three new difficulty levels, making it six now...
- Some enemies have new colours depending on how you play Keen
v1.4.4 Release:
---------------
......
......@@ -23,7 +23,8 @@ m_Dark(false),
mNumFuses(0),
mFuseInLevel(false),
m_Tilemaps(g_pGfxEngine->getTileMaps()),
mAnimtileTimer(0.0f)
mAnimtileTimer(0.0f),
mLocked(false)
{
resetScrolls();
m_Level = 0;
......@@ -219,6 +220,18 @@ void CMap::fetchNearestHorBlockers(const int y, int &upCoord, int &downCoord)
void CMap::unlock()
{
mLocked = false;
}
void CMap::lock()
{
mLocked = true;
}
bool CMap::findVerticalScrollBlocker(const int x)
{
......
......@@ -109,6 +109,17 @@ public:
void fetchNearestVertBlockers(const int x, int &leftCoord, int &rightCoord);
void fetchNearestHorBlockers(const int y, int &upCoord, int &downCoord);
/**
* Locks the map, the way, no one can switch to a new level. This is important when another player tries to enter
* a level, and the other hasn't even thrown the Flag (Galaxy)
*/
void unlock();
void lock();
bool locked()
{ return mLocked; }
Uint16 m_scrollx; // Amount of how much is scrolled on the map relative to (0,0) in X
......@@ -125,6 +136,7 @@ public:
int mNumFuses;
bool mFuseInLevel;
private:
bool findVerticalScrollBlocker(const int x);
......@@ -149,6 +161,8 @@ private:
std::string m_LevelName;
std::vector<int> scrollBlockX;
std::vector<int> scrollBlockY;
bool mLocked;
};
......
......@@ -825,6 +825,23 @@ void CSpriteObject::processEvents()
pObjMove->mSecond.processMove(move);
m_EventCont.pop_Event();
}
if( ObjMoveCouples* pObjMove = m_EventCont.occurredEvent<ObjMoveCouples>())
{
auto move = pObjMove->m_Vec;
auto playerVec = pObjMove->mCarriedObjVec;
processMove(move);
for(auto &player : playerVec)
{
if(!player->m_jumpdownfromobject)
player->processMove(move);
}
m_EventCont.pop_Event();
}
if( ObjMove* pObjMove = m_EventCont.occurredEvent<ObjMove>())
{
......
......@@ -270,7 +270,7 @@ public:
void processFallPhysics(const int boost);
void processFallPhysics();
virtual void processFalling();
virtual void getTouchedBy(CSpriteObject &theObject) {};
virtual void getTouchedBy(CSpriteObject &theObject) {}
virtual bool isNearby(CSpriteObject &theObject) { return true; }
virtual void getShotByRay(object_t &obj_type);
void kill_intersecting_tile(int mpx, int mpy, CSpriteObject &theObject);
......
......@@ -57,6 +57,8 @@ m_baseframe(0)
if(!newAction)
moveTo(m_destination);
pmap->lock();
}
void CFlag::getTouchedBy(CSpriteObject &theObject)
......@@ -114,6 +116,7 @@ void CFlag::processFlipping()
else
{
setAction(A_FLAG_WAVE);
mp_Map->unlock();
setActionSprite();
g_pSound->playSound( SOUND_FLAG_LAND );
......
......@@ -126,6 +126,9 @@ VectorD2<int> CPlayerWM::fetchFootDestCoord()
*/
void CPlayerWM::process()
{
if(mp_Map->locked())
return;
processInput();
// Perform animation cycle
......@@ -954,7 +957,7 @@ void CPlayerWM::startLevel(Uint16 object)
/*
* makes the player finish the level
*/
void CPlayerWM::finishLevel(const int object)
bool CPlayerWM::finishLevel(const int object)
{
// if a door or other blocker was found remove it
int x, y;
......@@ -1012,7 +1015,11 @@ void CPlayerWM::finishLevel(const int object)
// Mark the tileinfo on the map as level finished!! So player cannot just re-enter. Exception is if replayability is on.
mp_Map->setTile( x, y, 0, true, 2);
return true;
}
return false;
}
/**
......
......@@ -63,7 +63,7 @@ public:
void processLeavingTeleporter();
void startLevel(Uint16 object);
void finishLevel(const int object);
bool finishLevel(const int object);
// Checks if Keen in CK6 can climb
bool checkforClimbing(direction_t &climbDir);
......
......@@ -122,14 +122,17 @@ void CPlatform::process()
for(auto &carriedObj : mCarriedPlayerVec)
{
auto carriedPlayer = dynamic_cast<CPlayerLevel*>(carriedObj);
if(carriedObj == nullptr)
continue;
CPlayerLevel* carriedPlayer = dynamic_cast<CPlayerLevel*>(carriedObj);
if(!hitdetect(*carriedPlayer) || carriedPlayer->blockedu )
{
carriedPlayer->pSupportedbyobject = nullptr;
carriedPlayer->m_jumpdownfromobject = false;
carriedPlayer->dontdraw = false;
carriedPlayer = NULL;
carriedObj = nullptr;
}
else if(!carriedPlayer->m_jumpdownfromobject)
{
......@@ -146,6 +149,12 @@ void CPlatform::process()
}
}
if(!mCarriedPlayerVec.empty())
{
if(mCarriedPlayerVec.back() == nullptr)
mCarriedPlayerVec.pop_back();
}
processActionRoutine();
}
......@@ -201,8 +210,8 @@ void CPlatform::draw()
Sprite.drawSprite( showX, showY, (255-transluceny) );
for(auto &carriedObj : mCarriedPlayerVec)
{
CSprite &playSprite = g_pGfxEngine->getSprite(mSprVar,carriedObj->sprite);
{
CSprite &playSprite = g_pGfxEngine->getSprite(carriedObj->getSpriteVariantId(),carriedObj->sprite);
int distx = carriedObj->getXPosition()-getXPosition();
int disty = carriedObj->getYPosition()-getYPosition();
......
......@@ -88,7 +88,7 @@ void CPlatformHorizontal::draw()
{
// This draw routine also is able to draw a second object in case it is holding one.
if( dontdraw )
return;
return;
CSprite &Sprite = g_pGfxEngine->getSprite(mSprVar,sprite);
......@@ -99,36 +99,36 @@ void CPlatformHorizontal::draw()
if( scrx < gameres.w && scry < gameres.h && exists )
{
Uint16 showX = scrx+Sprite.getXOffset();
Uint16 showY = scry+Sprite.getYOffset();
CSprite &fireSprite = g_pGfxEngine->getSprite(mSprVar,m_FireSprite);
if(drawFire && xDirection == RIGHT)
fireSprite.drawSprite(showX-2, showY+8);
Sprite.drawSprite( showX, showY, (255-transluceny) );
if(drawFire && xDirection == LEFT)
fireSprite.drawSprite(showX+Sprite.getWidth()-6, showY+8);
Uint16 showX = scrx+Sprite.getXOffset();
Uint16 showY = scry+Sprite.getYOffset();
for( auto &player : mCarriedPlayerVec)
{
CSprite &playSprite = g_pGfxEngine->getSprite(mSprVar,player->sprite);
int distx = player->getXPosition()-getXPosition();
int disty = player->getYPosition()-getYPosition();
distx = (distx>>STC);
distx += (playSprite.getXOffset()-Sprite.getXOffset());
disty = (disty>>STC);
disty += (playSprite.getYOffset()-Sprite.getYOffset());
playSprite.drawSprite( showX+distx, showY+disty );
}
hasbeenonscreen = true;
}
CSprite &fireSprite = g_pGfxEngine->getSprite(mSprVar,m_FireSprite);
if(drawFire && xDirection == RIGHT)
fireSprite.drawSprite(showX-2, showY+8);
Sprite.drawSprite( showX, showY, (255-transluceny) );
if(drawFire && xDirection == LEFT)
fireSprite.drawSprite(showX+Sprite.getWidth()-6, showY+8);
for( auto &player : mCarriedPlayerVec)
{
CSprite &playSprite = g_pGfxEngine->getSprite(player->getSpriteVariantId(),player->sprite);
int distx = player->getXPosition()-getXPosition();
int disty = player->getYPosition()-getYPosition();
distx = (distx>>STC);
distx += (playSprite.getXOffset()-Sprite.getXOffset());
disty = (disty>>STC);
disty += (playSprite.getYOffset()-Sprite.getYOffset());
playSprite.drawSprite( showX+distx, showY+disty );
}
hasbeenonscreen = true;
}
}
}
......@@ -105,7 +105,7 @@ void CPlatformVertical::draw()
{
// This draw routine also is able to draw a second object in case it is holding one.
if( dontdraw )
return;
return;
CSprite &Sprite = g_pGfxEngine->getSprite(mSprVar,sprite);
......
......@@ -113,6 +113,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
inventory.Item.mLevelName = Map.getLevelName();
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==1) ? RIGHT : LEFT, inventory, m_Cheatmode, 0x89A, mPlayerID);
mPlayerID++;
break;
case 0x03:
......@@ -120,6 +121,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
// Add the Camera into the game scene and attach it to this player
inventory.Item.mLevelName = Map.getLevelName();
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, inventory, m_Cheatmode, 0x13E0, mPlayerID );
mPlayerID++;
break;
case 0x06: if( difficulty < HARD ) break;
......
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