Commit 396df9f2 authored by Gerhard Stein's avatar Gerhard Stein

Multiplayer Mode on World Map in Galaxy works!

parent d6e6d3f6
......@@ -31,13 +31,16 @@
namespace galaxy
{
CMapLoaderGalaxy::CMapLoaderGalaxy(CExeFile &ExeFile,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtr,
CInventory &Inventory, stCheat &Cheatmode):
m_ExeFile(ExeFile),
m_ObjectPtr(ObjectPtr),
m_Inventory(Inventory),
m_Cheatmode(Cheatmode)
m_Cheatmode(Cheatmode),
mPlayerID(0)
{}
// Gets returns the address of the datablock of the exe file, in where the
......
......@@ -53,6 +53,7 @@ protected:
CInventory &m_Inventory;
stCheat &m_Cheatmode;
std::string mLevelName;
int mPlayerID;
};
}
......
......@@ -144,8 +144,6 @@ const int CPlayerBase::mEpisodeActionNumMap[3][NUM_KEEN_ACTIONS] =
//{}
};
int CPlayerBase::numPlayers = 0;
CPlayerBase::CPlayerBase
(
CMap *pmap,
......@@ -154,12 +152,13 @@ CPlayerBase::CPlayerBase
Uint32 y,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode
stCheat &Cheatmode,
int playerID
) :
CGalaxySpriteObject(pmap, foeID, x, y),
m_Inventory(l_Inventory),
m_camera(pmap,x,y,this),
mPlayerNum(numPlayers++),
mPlayerNum(playerID),
m_Cheatmode(Cheatmode),
mp_processState(NULL)
{
......@@ -175,11 +174,6 @@ mp_processState(NULL)
m_camera.setPosition(m_Pos);
}
CPlayerBase::~CPlayerBase()
{
numPlayers--;
}
void CPlayerBase::getAnotherLife(const int lc_x, const int lc_y, const bool display, const bool alt)
{
......
......@@ -78,15 +78,15 @@ public:
* \description Basic Constructor. An Object always need the pointer to the Map of the level,
* Coordinates as also the type of the Object
*/
CPlayerBase(CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode);
CPlayerBase(CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode,
int playerID);
virtual ~CPlayerBase();
/**
* Pushes the players by the given object Reference
......@@ -183,7 +183,7 @@ protected:
static const int mEpisodeActionNumMap[3][NUM_KEEN_ACTIONS];
VectorD2<int> mTarget;
static int numPlayers;
//static int numPlayers;
};
};
......
......@@ -48,10 +48,10 @@ const int STUN_TIME = 30;
CPlayerLevel::CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode,
const size_t offset) :
CPlayerBase(pmap, foeID, x, y, facedir, l_Inventory, Cheatmode),
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode,
const size_t offset, const int playerID) :
CPlayerBase(pmap, foeID, x, y, facedir, l_Inventory, Cheatmode, playerID),
m_jumpdownfromobject(false),
mPlacingGem(false),
mPoleGrabTime(0),
......
......@@ -37,7 +37,7 @@ public:
CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
std::vector< std::shared_ptr<CGalaxySpriteObject> > &ObjectPtrs, direction_t facedir,
CInventory &l_Inventory, stCheat &Cheatmode,
const size_t offset);
const size_t offset, const int playerID);
void prepareToShoot();
......
......@@ -20,16 +20,18 @@ const int TIME_TO_WAVE = 400;
namespace galaxy {
CPlayerWM::CPlayerWM(CMap *pmap,
const Uint16 foeID,
Uint32 x,
Uint32 y,
CInventory &l_Inventory,
stCheat &Cheatmode,
const unsigned int actionoffset):
const Uint16 foeID,
Uint32 x,
Uint32 y,
CInventory &l_Inventory,
stCheat &Cheatmode,
const unsigned int actionoffset,
const int playerID):
CPlayerBase(pmap, foeID, x, y,
LEFT,
l_Inventory,
Cheatmode),
Cheatmode,
playerID),
m_basesprite(0),
m_teleportanibasetile(0),
m_teleportoldtile(0),
......
......@@ -21,7 +21,8 @@ public:
Uint32 y,
CInventory &l_Inventory,
stCheat &Cheatmode,
const unsigned int actionoffset);
const unsigned int actionoffset,
const int playerID);
VectorD2<int> fetchFootDestCoord();
......
......@@ -113,14 +113,15 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
case 0x02:
// This is the player on the map in one level
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==0x01) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x98C);
(foe==0x01) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x98C, mPlayerID);
mPlayerID++;
break;
case 0x03:
// This is the player on the world map
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_Inventory, m_Cheatmode, 0x15C2);
p_newfoe = new galaxy::CPlayerWM(&Map, foe, x, y, m_Inventory, m_Cheatmode, 0x15C2, mPlayerID);
mPlayerID++;
break;
case 0x04:
......@@ -273,7 +274,8 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp4::addFoe(CMap &Map, word foe, size_t x,
case 0x2A:
// This is Keen in the swimming suit
p_newfoe = new galaxy::CPlayerDive(&Map, foe, x, y,
RIGHT, m_Inventory, m_Cheatmode);
RIGHT, m_Inventory, m_Cheatmode, mPlayerID);
mPlayerID++;
break;
case 0x2C: if( difficulty < HARD ) break;
......
......@@ -21,11 +21,13 @@ CPlayerDive::CPlayerDive(CMap *pmap,
Uint32 y,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode) :
stCheat &Cheatmode,
const int playerID) :
CPlayerBase(pmap, foeID, x, y,
facedir,
l_Inventory,
Cheatmode),
Cheatmode,
playerID),
m_swimupspeed(0),
m_breathtimer(0)
{
......
......@@ -21,7 +21,8 @@ public:
Uint32 y,
direction_t facedir,
CInventory &l_Inventory,
stCheat &Cheatmode);
stCheat &Cheatmode,
const int playerID);
void kill(const bool force = false);
void process();
......
......@@ -119,13 +119,13 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp5::addFoe(CMap &Map, word foe, size_t x,
case 0x02:
// This is the player on the map in one level
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==1) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x0888);
(foe==1) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x0888, mPlayerID);
break;
case 0x03:
// This is the player on the world map
// Add the Camera into the game scene and attach it to this player
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x146E );
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x146E, mPlayerID );
// 0x137A
break;
......
......@@ -105,7 +105,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
case 0x02:
// This is the player on the map in one level
p_newfoe = new galaxy::CPlayerLevel(&Map, foe, x, y, m_ObjectPtr,
(foe==1) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x89A);
(foe==1) ? RIGHT : LEFT, m_Inventory, m_Cheatmode, 0x89A, mPlayerID);
break;
case 0x03:
......@@ -114,7 +114,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
//p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x130A );
//p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x13DE );
//p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x1218 );
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x13E0 );
p_newfoe = new galaxy::CPlayerWM(&Map,foe, x, y, m_Inventory, m_Cheatmode, 0x13E0, 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