Commit 53bb6937 authored by Gerhard Stein's avatar Gerhard Stein

Added inventory and made slight adaptations to the sprite item class. Now it...

Added inventory and made slight adaptations to the sprite item class. Now it should work correctly. Try to collect gems ;-)
parent 2be0b6dd
/*
* CInventory.cpp
*
* Created on: 25.11.2010
* Author: gerstrong
*/
#include "CInventory.h"
CInventory::CInventory() {
// TODO Auto-generated constructor stub
}
CInventory::~CInventory() {
// TODO Auto-generated destructor stub
}
/*
* CInventory.h
*
* Created on: 25.11.2010
* Author: gerstrong
*
* The new Galaxy Inventory. We have another class here, because
* the one for vorticon is memory fixed for savegames.
*/
#ifndef CINVENTORY_H_
#define CINVENTORY_H_
class CInventory {
public:
CInventory();
virtual ~CInventory();
};
#endif /* CINVENTORY_H_ */
......@@ -45,7 +45,19 @@ void CLevelPlay::process()
CObject* p_Object = m_ObjectPtr[i];
if(p_Object->exists)
{
p_Object->process();
// Check collision between objects
/*for( std::vector<CObject*>::iterator theOtherObj=m_ObjectPtr.begin() ;
theOtherObj != m_ObjectPtr.end() ; theOtherObj++ )*/
for(size_t j=0 ; j<m_ObjectPtr.size() ; j++)
{
CObject *theOtherObj = m_ObjectPtr[j];
if( theOtherObj != p_Object )
p_Object->getTouchedBy(*theOtherObj);
}
}
}
g_pVideoDriver->blitScrollSurface();
......@@ -66,7 +78,6 @@ void CLevelPlay::process()
if(!(*obj)->honorPriority)
(*obj)->draw();
}
}
}
......@@ -21,6 +21,7 @@
#include "engine/galaxy/ai/CMiragia.h"
#include "engine/galaxy/ai/CPlayerWM.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
#include "engine/galaxy/ai/CSpriteItem.h"
#include <fstream>
......@@ -307,6 +308,29 @@ void CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, size_t y)
CCamera *camera = NULL;
VectorD2<Uint32> Location(x,y);
// Point Item Sprites (Candies, etc...)
for( Uint32 i=61 ; i<=67 ; i++ )
{
if( foe == i )
{
const Uint32 newsprite = 103+2*(i-61);
p_newfoe = new galaxy::CSpriteItem(&Map, x, y, m_ObjectPtr, newsprite);
}
}
if( foe == 68 )
p_newfoe = new galaxy::CSpriteItem(&Map, x, y, m_ObjectPtr, 127);
for( Uint32 i=57 ; i<=60 ; i++ )
{
if( foe == i )
{
const Uint32 newsprite = 118+2*(i-57);
p_newfoe = new galaxy::CSpriteItem(&Map, x, y, m_ObjectPtr, newsprite);
}
}
switch(foe)
{
case 1:
......
......@@ -693,6 +693,7 @@ void CPlayerLevel::processLevelMiscFlagsCheck()
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, lc_x<<CSF, lc_y<<CSF, 215, ANIMATE));
}
/// Tile Items (Sprite are handled in the CSpriteItem Class)
// All the collectable items go from 21 to 28
for( Uint16 i=21 ; i<=28 ; i++ )
{
......
......@@ -6,19 +6,59 @@
*/
#include "CSpriteItem.h"
#include "CItemEffect.h"
CSpriteItem::CSpriteItem(CMap *pmap, Uint32 x, Uint32 y) :
CObject(pmap, x, y, OBJ_NONE)
{
// TODO Auto-generated constructor stub
namespace galaxy {
const int MAX_ANIMATION_TIMER = 20;
CSpriteItem::CSpriteItem(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>& ObjectPtrs, Uint32 sprite) :
CObject(pmap, x, y, OBJ_NONE),
m_ObjectPtrs(ObjectPtrs)
{
m_index = sprite;
m_basesprite = sprite;
m_timer = (y*256+x)%MAX_ANIMATION_TIMER;
this->sprite = (m_timer%2 == 0) ? m_basesprite : m_basesprite+1;
calcBouncingBoxes();
inhibitfall = true;
}
void CSpriteItem::process()
{
// Do the animation stuff here!
if(m_timer == 0)
{
this->sprite = (m_basesprite == this->sprite) ? m_basesprite + 1 : m_basesprite;
}
if(m_timer < MAX_ANIMATION_TIMER)
m_timer++;
else
m_timer = 0;
}
void CSpriteItem::getTouchedBy(CObject &theObject)
{
if(hitdetect(theObject))
{
exists = false;
Uint32 newanimsprite = got_sprite_item_pics[0];
/// Calculate the right animation.
// Point items
if( m_basesprite >= 103 && m_basesprite <= 116 )
newanimsprite = got_sprite_item_pics[4+(m_basesprite-103)/2];
// raygun
if( m_basesprite >= 127 && m_basesprite <= 128 )
newanimsprite = got_sprite_item_pics[11];
m_ObjectPtrs.push_back(new CItemEffect(mp_Map, getXPosition(), getYPosition(), newanimsprite));
}
}
CSpriteItem::~CSpriteItem() {
// TODO Auto-generated destructor stub
}
......@@ -14,14 +14,22 @@
#include "common/CObject.h"
namespace galaxy {
class CSpriteItem : public CObject{
public:
CSpriteItem(CMap *pmap, Uint32 x, Uint32 y);
CSpriteItem(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CObject*>& ObjectPtrs, Uint32 sprite);
void process();
virtual ~CSpriteItem();
void getTouchedBy(CObject &theObject);
private:
int m_timer;
Uint32 m_basesprite;
std::vector<CObject*>& m_ObjectPtrs;
};
}
#endif /* CSPRITEITEM_H_ */
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