Commit 62e6d938 authored by Gerhard Stein's avatar Gerhard Stein

added code to the inventory class for the galaxy engine and some cleanups

parent 53bb6937
......@@ -7,11 +7,25 @@
#include "CInventory.h"
CInventory::CInventory() {
// TODO Auto-generated constructor stub
CInventory::CInventory()
{
reset();
}
CInventory::~CInventory() {
// TODO Auto-generated destructor stub
void CInventory::reset()
{
m_lifes = 3;
m_points = 0;
m_lifeAt = 20000;
m_drops = 0;
m_bullets = 0;
m_gem.red = 0;
m_gem.blue = 0;
m_gem.green = 0;
m_gem.yellow = 0;
m_keycards = 0;
m_special.ep4.elders = 0;
m_special.ep4.swimsuit = 0;
}
......@@ -14,7 +14,38 @@
class CInventory {
public:
CInventory();
virtual ~CInventory();
void reset();
private:
int m_lifes;
int m_points;
int m_lifeAt;
int m_drops;
int m_bullets;
struct {
int red;
int blue;
int green;
int yellow;
} m_gem;
int m_keycards;
union {
struct
{
bool swimsuit;
int elders;
}ep4;
struct
{
bool sandwich;
bool hook;
bool rocketKeycard;
}ep6;
}m_special;
};
#endif /* CINVENTORY_H_ */
......@@ -23,10 +23,10 @@ bool CLevelPlay::isActive()
void CLevelPlay::setActive(bool value)
{ m_active = value; }
bool CLevelPlay::loadLevel(Uint16 level)
bool CLevelPlay::loadLevel(Uint16 level, CInventory &Inventory)
{
// Load the World map level.
CMapLoaderGalaxy MapLoader(m_ExeFile, m_ObjectPtr);
CMapLoaderGalaxy MapLoader(m_ExeFile, m_ObjectPtr, Inventory);
m_Map.setScrollSurface(g_pVideoDriver->getScrollSurface());
MapLoader.loadMap(m_Map, level);
......
......@@ -12,6 +12,7 @@
#include "common/CObject.h"
#include "fileio/CExeFile.h"
#include "engine/galaxy/CInventory.h"
#include <vector>
namespace galaxy {
......@@ -22,7 +23,7 @@ public:
bool isActive();
void setActive(bool value);
bool loadLevel(Uint16 level);
bool loadLevel(Uint16 level, CInventory &Inventory);
void process();
......
......@@ -25,9 +25,10 @@
#include <fstream>
CMapLoaderGalaxy::CMapLoaderGalaxy(CExeFile &ExeFile, std::vector<CObject*>& ObjectPtr):
CMapLoaderGalaxy::CMapLoaderGalaxy(CExeFile &ExeFile, std::vector<CObject*>& ObjectPtr, CInventory &Inventory):
m_ExeFile(ExeFile),
m_ObjectPtr(ObjectPtr)
m_ObjectPtr(ObjectPtr),
m_Inventory(Inventory)
{}
// Gets returns the address of the datablock of the exe file, in where the
......@@ -336,7 +337,7 @@ void CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
case 1:
case 2:
// This is the player on map
p_newfoe = new galaxy::CPlayerLevel(&Map, x, y, m_ObjectPtr, (foe==1) ? RIGHT : LEFT );
p_newfoe = new galaxy::CPlayerLevel(&Map, x, y, m_ObjectPtr, (foe==1) ? RIGHT : LEFT, m_Inventory);
// Add the Camera into the game scene and attach it to this player
camera = new CCamera(&Map,x,y);
......@@ -366,8 +367,3 @@ void CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
if(p_newfoe)
m_ObjectPtr.push_back(p_newfoe);
}
CMapLoaderGalaxy::~CMapLoaderGalaxy()
{
// TODO Auto-generated destructor stub
}
......@@ -8,10 +8,11 @@
#ifndef CMAPLOADERGALAXY_H_
#define CMAPLOADERGALAXY_H_
#include "../../fileio/CExeFile.h"
#include "../../fileio/TypeDefinitions.h"
#include "../../common/CMap.h"
#include "../../common/CObject.h"
#include "fileio/CExeFile.h"
#include "fileio/TypeDefinitions.h"
#include "common/CMap.h"
#include "engine/galaxy/CInventory.h"
#include "common/CObject.h"
#include <vector>
#include <string>
......@@ -20,13 +21,12 @@
class CMapLoaderGalaxy
{
public:
CMapLoaderGalaxy(CExeFile &ExeFile, std::vector<CObject*>& ObjectPtr);
CMapLoaderGalaxy(CExeFile &ExeFile, std::vector<CObject*>& ObjectPtr, CInventory &Inventory);
size_t getMapheadOffset();
bool gotoSignature(std::ifstream &MapFile);
bool loadMap(CMap &Map, Uint8 level);
void spawnFoes(CMap &Map);
void addFoe(CMap &Map, word foe, size_t x, size_t y);
virtual ~CMapLoaderGalaxy();
private:
void unpackPlaneData(std::ifstream &MapFile,
......@@ -36,6 +36,7 @@ private:
CExeFile &m_ExeFile;
std::vector<CObject*>& m_ObjectPtr;
CInventory &m_Inventory;
};
#endif /* CMAPLOADERGALAXY_H_ */
......@@ -20,7 +20,7 @@ CPlayGameGalaxy::CPlayGameGalaxy(CExeFile &ExeFile, char level,
char numplayers, Uint8& difficulty,
stOption *p_option, CSavedGame &SavedGame) :
CPlayGame(ExeFile, level, numplayers, difficulty, p_option),
m_WorldMap(ExeFile),
m_WorldMap(ExeFile, m_Inventory),
m_LevelPlay(ExeFile),
mp_Menu(NULL),
m_SavedGame(SavedGame)
......@@ -42,7 +42,7 @@ bool CPlayGameGalaxy::init()
else
{
// manually a level has been loaded
m_LevelPlay.loadLevel(m_Level);
m_LevelPlay.loadLevel(m_Level, m_Inventory);
m_LevelPlay.setActive(true);
return true;
}
......@@ -103,7 +103,7 @@ void CPlayGameGalaxy::process()
if(ev->data > 0xC000)
{
m_WorldMap.setActive(false);
m_LevelPlay.loadLevel(ev->data - 0xC000);
m_LevelPlay.loadLevel(ev->data - 0xC000, m_Inventory);
m_LevelPlay.setActive(true);
}
EventContainer.pop_Event();
......
......@@ -9,6 +9,7 @@
#define CPLAYGAMEGALAXY_H_
#include "engine/playgame/CPlayGame.h"
#include "engine/galaxy/CInventory.h"
#include "common/CMap.h"
#include "CWorldMap.h"
#include "CLevelPlay.h"
......@@ -43,6 +44,7 @@ private:
CMenuGalaxy *mp_Menu;
CSavedGame &m_SavedGame;
CBitmap m_BackgroundBitmap;
CInventory m_Inventory;
};
}
......
......@@ -7,15 +7,16 @@
#include "CWorldMap.h"
#include "CMapLoaderGalaxy.h"
#include "../../sdl/CInput.h"
#include "../../sdl/CVideoDriver.h"
#include "../../StringUtils.h"
#include "sdl/CInput.h"
#include "sdl/CVideoDriver.h"
#include "StringUtils.h"
namespace galaxy {
CWorldMap::CWorldMap(CExeFile &ExeFile):
CWorldMap::CWorldMap(CExeFile &ExeFile, CInventory &Inventory):
m_active(false),
m_ExeFile(ExeFile)
m_ExeFile(ExeFile),
m_Inventory(Inventory)
{}
bool CWorldMap::isActive()
......@@ -36,7 +37,7 @@ void CWorldMap::setActive(bool value)
void CWorldMap::init()
{
// Load the World map level.
CMapLoaderGalaxy MapLoader(m_ExeFile, m_ObjectPtr);
CMapLoaderGalaxy MapLoader(m_ExeFile, m_ObjectPtr, m_Inventory);
m_Map.setScrollSurface(g_pVideoDriver->getScrollSurface());
MapLoader.loadMap(m_Map, 0); // Map Level?
......
......@@ -12,13 +12,14 @@
#include "common/CObject.h"
#include "fileio/CExeFile.h"
#include "engine/galaxy/CInventory.h"
#include <vector>
namespace galaxy {
class CWorldMap {
public:
CWorldMap(CExeFile &ExeFile);
CWorldMap(CExeFile &ExeFile, CInventory &Inventory);
bool isActive();
void setActive(bool value);
......@@ -33,6 +34,7 @@ private:
CMap m_Map;
CExeFile &m_ExeFile;
CInventory &m_Inventory;
};
}
......
......@@ -30,13 +30,15 @@ const int POGO_X_BOOST = 4;
const int POGO_START_INERTIA_IMPOSSIBLE = -200;
CPlayerLevel::CPlayerLevel(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>& ObjectPtrs, direction_t facedir) :
std::vector<CObject*>& ObjectPtrs, direction_t facedir,
CInventory &l_Inventory) :
CObject(pmap, x, y, OBJ_NONE),
m_animation(0),
m_animation_time(1),
m_animation_ticker(0),
m_ObjectPtrs(ObjectPtrs),
m_cliff_hanging(false)
m_cliff_hanging(false),
m_Inventory(l_Inventory)
{
m_index = 0;
m_timer = 0;
......
......@@ -10,6 +10,7 @@
#include "common/CObject.h"
#include "engine/CEvent.h"
#include "engine/galaxy/CInventory.h"
namespace galaxy {
......@@ -57,7 +58,7 @@ PA_MAX_ACTIONS
class CPlayerLevel : public CObject {
public:
CPlayerLevel(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>& ObjectPtrs, direction_t facedir);
std::vector<CObject*>& ObjectPtrs, direction_t facedir, CInventory &l_Inventory);
void process();
void processInput();
......@@ -89,6 +90,9 @@ private:
bool m_inair;
int m_timer;
CInventory &m_Inventory;
};
}
......
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