[Clonekeenplus-commits] [SCM] clonekeenplus branch, master, updated. 49bfca52b52101924fca807787aa6d
Commander Keen Interpreter
Brought to you by:
gerstrong
From: Gerstrong <ger...@us...> - 2010-11-25 18:35:29
|
via 49bfca52b52101924fca807787aa6d6a8e8b1ebc (commit) via 62e6d9385b12ae190104fe9e955b2647bfdb2027 (commit) from 53bb69378e215b0e87ce9311ffb501a10b940628 (commit) - Log ----------------------------------------------------------------- commit 49bfca52b52101924fca807787aa6d6a8e8b1ebc Author: Gerhard Stein <ger...@gm...> Date: Thu Nov 25 19:34:39 2010 +0100 fixes commit 62e6d9385b12ae190104fe9e955b2647bfdb2027 Author: Gerhard Stein <ger...@gm...> Date: Thu Nov 25 18:45:48 2010 +0100 added code to the inventory class for the galaxy engine and some cleanups ----------------------------------------------------------------------- Summary of changes: src/engine/galaxy/CInventory.cpp | 24 +++++++++++++++++++----- src/engine/galaxy/CInventory.h | 32 +++++++++++++++++++++++++++++++- src/engine/galaxy/CLevelPlay.cpp | 4 ++-- src/engine/galaxy/CLevelPlay.h | 3 ++- src/engine/galaxy/CMapLoaderGalaxy.cpp | 12 ++++-------- src/engine/galaxy/CMapLoaderGalaxy.h | 13 +++++++------ src/engine/galaxy/CPlayGameGalaxy.cpp | 7 +++---- src/engine/galaxy/CPlayGameGalaxy.h | 2 ++ src/engine/galaxy/CWorldMap.cpp | 15 ++++++++------- src/engine/galaxy/CWorldMap.h | 4 +++- src/engine/galaxy/ai/CPlayerLevel.cpp | 19 +++++++++++++++++-- src/engine/galaxy/ai/CPlayerLevel.h | 6 +++++- src/engine/galaxy/ai/CSpriteItem.cpp | 25 +++++++++++++++++++++++++ 13 files changed, 128 insertions(+), 38 deletions(-) diff --git a/src/engine/galaxy/CInventory.cpp b/src/engine/galaxy/CInventory.cpp index 889c625..1684441 100644 --- a/src/engine/galaxy/CInventory.cpp +++ b/src/engine/galaxy/CInventory.cpp @@ -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; } diff --git a/src/engine/galaxy/CInventory.h b/src/engine/galaxy/CInventory.h index 9fb3809..3afc0c2 100644 --- a/src/engine/galaxy/CInventory.h +++ b/src/engine/galaxy/CInventory.h @@ -14,7 +14,37 @@ class CInventory { public: CInventory(); - virtual ~CInventory(); + + void reset(); + + 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_ */ diff --git a/src/engine/galaxy/CLevelPlay.cpp b/src/engine/galaxy/CLevelPlay.cpp index 207507a..f081ee6 100644 --- a/src/engine/galaxy/CLevelPlay.cpp +++ b/src/engine/galaxy/CLevelPlay.cpp @@ -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); diff --git a/src/engine/galaxy/CLevelPlay.h b/src/engine/galaxy/CLevelPlay.h index aea4be8..1927e43 100644 --- a/src/engine/galaxy/CLevelPlay.h +++ b/src/engine/galaxy/CLevelPlay.h @@ -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(); diff --git a/src/engine/galaxy/CMapLoaderGalaxy.cpp b/src/engine/galaxy/CMapLoaderGalaxy.cpp index 664509c..ad6a81d 100644 --- a/src/engine/galaxy/CMapLoaderGalaxy.cpp +++ b/src/engine/galaxy/CMapLoaderGalaxy.cpp @@ -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 -} diff --git a/src/engine/galaxy/CMapLoaderGalaxy.h b/src/engine/galaxy/CMapLoaderGalaxy.h index f3fb92b..5f9a796 100644 --- a/src/engine/galaxy/CMapLoaderGalaxy.h +++ b/src/engine/galaxy/CMapLoaderGalaxy.h @@ -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_ */ diff --git a/src/engine/galaxy/CPlayGameGalaxy.cpp b/src/engine/galaxy/CPlayGameGalaxy.cpp index b81771f..42f47ed 100644 --- a/src/engine/galaxy/CPlayGameGalaxy.cpp +++ b/src/engine/galaxy/CPlayGameGalaxy.cpp @@ -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(); @@ -125,7 +125,6 @@ void CPlayGameGalaxy::processInput() mp_Menu = new CMenuGalaxy(ACTIVE, m_ExeFile, m_SavedGame, mp_option, m_restartVideo); m_BackgroundBitmap = *g_pGfxEngine->getBitmap("KEENSWATCH"); } - } /* diff --git a/src/engine/galaxy/CPlayGameGalaxy.h b/src/engine/galaxy/CPlayGameGalaxy.h index 7e0a2ba..300152a 100644 --- a/src/engine/galaxy/CPlayGameGalaxy.h +++ b/src/engine/galaxy/CPlayGameGalaxy.h @@ -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; }; } diff --git a/src/engine/galaxy/CWorldMap.cpp b/src/engine/galaxy/CWorldMap.cpp index ff68b70..2f45217 100644 --- a/src/engine/galaxy/CWorldMap.cpp +++ b/src/engine/galaxy/CWorldMap.cpp @@ -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,10 +37,10 @@ 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? + MapLoader.loadMap(m_Map, 0); // Is it a Map Level? m_Map.drawAll(); } diff --git a/src/engine/galaxy/CWorldMap.h b/src/engine/galaxy/CWorldMap.h index d324af1..41d2ea8 100644 --- a/src/engine/galaxy/CWorldMap.h +++ b/src/engine/galaxy/CWorldMap.h @@ -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; }; } diff --git a/src/engine/galaxy/ai/CPlayerLevel.cpp b/src/engine/galaxy/ai/CPlayerLevel.cpp index 4a6bd2f..315e67c 100644 --- a/src/engine/galaxy/ai/CPlayerLevel.cpp +++ b/src/engine/galaxy/ai/CPlayerLevel.cpp @@ -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; @@ -48,6 +50,8 @@ m_cliff_hanging(false) m_pfiring = false; m_jumpheight = 0; + m_climbing = false; + m_inair = false; processActionRoutine(); CSprite &rSprite = g_pGfxEngine->getSprite(sprite); @@ -675,6 +679,17 @@ void CPlayerLevel::processLevelMiscFlagsCheck() if( hitdetectWithTileProperty(i, l_x, l_y) ) { + if(i == 7 && m_Inventory.m_gem.red > 0) + m_Inventory.m_gem.red--; + else if(i == 8 && m_Inventory.m_gem.yellow > 0) + m_Inventory.m_gem.yellow--; + else if(i == 9 && m_Inventory.m_gem.blue > 0) + m_Inventory.m_gem.blue--; + else if(i == 10 && m_Inventory.m_gem.green > 0) + m_Inventory.m_gem.green--; + else + break; + setAction(A_KEEN_SLIDE); } } diff --git a/src/engine/galaxy/ai/CPlayerLevel.h b/src/engine/galaxy/ai/CPlayerLevel.h index 90a0504..541e2d9 100644 --- a/src/engine/galaxy/ai/CPlayerLevel.h +++ b/src/engine/galaxy/ai/CPlayerLevel.h @@ -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(); @@ -75,6 +76,8 @@ public: void openDoorsTile(); void processPlaceGem(); + CInventory &m_Inventory; + private: Uint8 m_animation; Uint8 m_animation_time; @@ -89,6 +92,7 @@ private: bool m_inair; int m_timer; + }; } diff --git a/src/engine/galaxy/ai/CSpriteItem.cpp b/src/engine/galaxy/ai/CSpriteItem.cpp index 34c7e13..f5ab7f5 100644 --- a/src/engine/galaxy/ai/CSpriteItem.cpp +++ b/src/engine/galaxy/ai/CSpriteItem.cpp @@ -7,6 +7,7 @@ #include "CSpriteItem.h" #include "CItemEffect.h" +#include "CPlayerLevel.h" namespace galaxy { @@ -47,6 +48,9 @@ void CSpriteItem::getTouchedBy(CObject &theObject) { exists = false; + //CPlayerLevel &Player = dynamic_cast<CPlayerLevel&>(theObject); + CPlayerLevel *pPlayer = (CPlayerLevel*)(&theObject); + Uint32 newanimsprite = got_sprite_item_pics[0]; /// Calculate the right animation. // Point items @@ -58,6 +62,27 @@ void CSpriteItem::getTouchedBy(CObject &theObject) newanimsprite = got_sprite_item_pics[11]; m_ObjectPtrs.push_back(new CItemEffect(mp_Map, getXPosition(), getYPosition(), newanimsprite)); + + + // Now add the stuff to the inventory + + switch(m_basesprite) + { + case 118: + pPlayer->m_Inventory.m_gem.red++; + break; + case 120: + pPlayer->m_Inventory.m_gem.yellow++; + break; + case 122: + pPlayer->m_Inventory.m_gem.blue++; + break; + case 124: + pPlayer->m_Inventory.m_gem.green++; + break; + default: + break; + } } } hooks/post-receive -- clonekeenplus |