Commit 059b24ed authored by Gerhard Stein's avatar Gerhard Stein

item disappear when Keen touches them. Still a lot has to be done!

parent 6eed530b
......@@ -3,6 +3,8 @@ Commander Genius Release :
v0.3.2.5:
---------
- Keen now can climb poles (Galaxy)
- Keen now can hang on cliff and climb then up (Galaxy)
- improved some galaxy physics
v0.3.2.4:
......
......@@ -126,6 +126,7 @@ public:
virtual void process() { }
bool hitdetect(CObject &hitobject);
bool hitdetectWithTilePropertyRect(const Uint16 Property, SDL_Rect &rect, const int res);
bool hitdetectWithTileProperty(Uint16 Property, Uint16 x, Uint16 y);
virtual void kill();
void blink(Uint16 frametime);
......
......@@ -321,6 +321,34 @@ bool CObject::hitdetect(CObject &hitobject)
return true;
}
/**
* \brief this new type of hit detection only checks if the foe touches something that has that property tile
* \param Property The Tile Property we are looking
* \param from x
* \return true if detection worked with that tile having the property, else false
*/
bool CObject::hitdetectWithTilePropertyRect(const Uint16 Property, SDL_Rect &rect, const int res)
{
std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
for( Uint16 i=0 ; i<rect.w ; i+=res )
{
for( Uint16 j=0 ; j<rect.h ; j+=res )
{
const char behavior = Tile[mp_Map->getPlaneDataAt(1, rect.x+i, rect.y+j)].behaviour;
if(behavior == Property || behavior == Property-128 ) // -128 for foreground properties
{
rect.x = rect.x+i;
rect.y = rect.y+j;
return true;
}
}
}
return false;
}
/**
* \brief this new type of hit detection only checks if the foe touches something that has that property
* \param Property The Tile Property we are looking
......@@ -328,15 +356,12 @@ bool CObject::hitdetect(CObject &hitobject)
*/
bool CObject::hitdetectWithTileProperty(Uint16 Property, Uint16 x, Uint16 y)
{
char behavior;
std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
behavior = Tile[mp_Map->getPlaneDataAt(1, x, y)].behaviour;
const char behavior = Tile[mp_Map->getPlaneDataAt(1, x, y)].behaviour;
if(behavior == Property || behavior == Property-128 ) // +128 for foreground properties
return true;
return false;
else
return false;
}
bool CObject::checkSolidR( int x1, int x2, int y1, int y2)
......
......@@ -74,6 +74,8 @@ void CPlayerLevel::process()
processExiting();
processItemCollection();
processActionRoutine();
moveXDir(xinertia);
......@@ -421,4 +423,27 @@ void CPlayerLevel::processExiting()
}
}
// Process the item collecting
void CPlayerLevel::processItemCollection()
{
// TODO: Here it a lot we have to do still.
// Item which are taken must go into a data structure
// animation should also be triggered
// All the collectable items go from 21 to 28
for( Uint16 i=4 ; i<=28 ; i++ )
{
SDL_Rect rect;
rect.x = getXLeftPos();
rect.y = getYUpPos();
rect.w = getXRightPos() - getXLeftPos();
rect.h = getYDownPos() - getYUpPos();
if(hitdetectWithTilePropertyRect(i, rect, 1<<STC))
{
mp_Map->setTile(rect.x>>CSF, rect.y>>CSF, 0, true, 1);
}
}
}
}
......@@ -67,6 +67,7 @@ public:
void processJumping();
void processLooking();
void processExiting();
void processItemCollection();
private:
Uint8 m_animation;
......
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