Commit d53c93fa authored by Gerhard Stein's avatar Gerhard Stein

More cleanups in galaxy

parent 0b29fcbc
/*
* CGalaxySpriteObject.cpp
*
* Created on: 21.06.2012
* Author: gerstrong
*/
#include "CGalaxySpriteObject.h"
CGalaxySpriteObject::CGalaxySpriteObject(CMap *pmap, Uint32 x, Uint32 y, object_t type) :
CSpriteObject(pmap, x, y, type)
{}
/*
* CGalaxySpriteObject.h
*
* Created on: 21.06.2012
* Author: gerstrong
*/
#ifndef CGALAXYSPRITEOBJECT_H_
#define CGALAXYSPRITEOBJECT_H_
#include "common/CSpriteObject.h"
class CGalaxySpriteObject: public CSpriteObject
{
CGalaxySpriteObject(CMap *pmap, Uint32 x, Uint32 y, object_t type);
};
#endif /* CGALAXYSPRITEOBJECT_H_ */
......@@ -434,7 +434,7 @@ void CVorticonMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
case 21:
// This is a Mad Mushroom.
p_newfoe = new galaxy::CMadMushroom(&Map, x, y);
p_newfoe = new galaxy::CMadMushroom(&Map, x, y-(2<<CSF));
break;
......
......@@ -110,18 +110,27 @@ void CMapPlayGalaxy::process(const bool msgboxactive)
std::vector<CSpriteObject*>::reverse_iterator obj;
// Draw all the sprites but no player
// Draw all the sprites without player
// The player sprites are drawn as last
galaxy::CPlayerBase *player = NULL;
for( obj=m_ObjectPtr.rbegin() ;
obj!=m_ObjectPtr.rend() ; obj++ )
{
if((*obj)->honorPriority && (*obj)->m_type != OBJ_PLAYER)
if( galaxy::CPlayerBase* newplayer = dynamic_cast<galaxy::CPlayerBase*>(*obj) )
{
player = newplayer;
continue;
}
if((*obj)->honorPriority )
(*obj)->draw();
}
// Now only draw the player sprite. So everything expect maked tiles are below his layer
for( obj = m_ObjectPtr.rbegin() ; obj!=m_ObjectPtr.rend() ; obj++ )
if((*obj)->m_type == OBJ_PLAYER)
(*obj)->draw();
if(player)
{
player->draw();
}
// Draw masked tiles here!
m_Map.drawForegroundTiles();
......
......@@ -29,7 +29,8 @@ namespace galaxy
#define A_KEEN_DIE 29
class CPlayerBase : public CSpriteObject {
class CPlayerBase : public CSpriteObject
{
public:
/**
* \description Basic Constructor. An Object always need the pointer to the Map of the level,
......
......@@ -14,7 +14,8 @@
namespace galaxy
{
class CStunnable: public virtual CSpriteObject {
class CStunnable: public virtual CSpriteObject
{
public:
CStunnable( CMap *pmap,
Uint32 x,
......
......@@ -10,6 +10,7 @@
#include "misc.h"
#include "sdl/sound/CSound.h"
#include "sdl/music/CMusic.h"
#include <typeinfo>
namespace galaxy {
......@@ -111,10 +112,10 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
return;
// When Keen touches the Council Member exit the level and add one to the council list
if(theObject.m_type == OBJ_PLAYER)
//if( typeid(theObject) == typeid(CPlayerLevel) )
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
int &rescuedelders = Player.m_Inventory.Item.m_special.ep4.elders;
int &rescuedelders = player->m_Inventory.Item.m_special.ep4.elders;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
......@@ -125,7 +126,7 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
std::string elder_text[2];
if(Player.m_Inventory.Item.m_special.ep4.swimsuit) // Under water the text is a bit different
if(player->m_Inventory.Item.m_special.ep4.swimsuit) // Under water the text is a bit different
{
elder_text[0] = g_pBehaviorEngine->getString("ELDERS_UNDERWATER_TEXT");
elder_text[1] = "";
......
......@@ -27,10 +27,9 @@ void CDiveSuit::getTouchedBy(CSpriteObject &theObject)
return;
// When Keen touches the Council Member exit the level and add one to the council list
if(theObject.m_type == OBJ_PLAYER)
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
CPlayerLevel &Player = static_cast<CPlayerLevel&>(theObject);
bool &swimsuit = Player.m_Inventory.Item.m_special.ep4.swimsuit;
bool &swimsuit = player->m_Inventory.Item.m_special.ep4.swimsuit;
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
......
......@@ -6,6 +6,7 @@
*/
#include "CLindsey.h"
#include "../CPlayerLevel.h"
namespace galaxy {
......@@ -49,7 +50,7 @@ void CLindsey::process()
void CLindsey::getTouchedBy(CSpriteObject &theObject)
{
// When Keen touches the pincess give that hint
if(theObject.m_type == OBJ_PLAYER)
if( dynamic_cast<CPlayerLevel*>(&theObject) )
{
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
......
......@@ -79,16 +79,14 @@ void CPlatform::process()
void CPlatform::getTouchedBy(CSpriteObject &theObject)
{
if(theObject.m_type == OBJ_PLAYER)
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
CPlayerLevel &Player = dynamic_cast<CPlayerLevel&>(theObject);
const int m_py2 = Player.getYDownPos();
const int m_py2 = player->getYDownPos();
const int m_y2 = getYUpPos()+(4<<STC);
if( m_py2 <= m_y2 && !Player.supportedbyobject && !Player.m_jumpdownfromobject )
if( m_py2 <= m_y2 && !player->supportedbyobject && !player->m_jumpdownfromobject )
{
mp_CarriedPlayer = &Player;
Player.supportedbyobject = true;
mp_CarriedPlayer = player;
player->supportedbyobject = true;
}
}
}
......
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