Commit b1bae2f9 authored by Gerhard Stein's avatar Gerhard Stein

More AI for the Egg. Bird is next!

parent c9206dba
......@@ -227,24 +227,23 @@ void CSpriteObject::moveDown(const int amnt)
// This decreases the inertia we have of the object in X-direction.
// It should be used for objects, where it must be assured, that the inertia can get
// zero and not pass that limit
void CSpriteObject::decreaseXInertia(const int& value)
void CSpriteObject::decreaseXInertia(const int value)
{
if(xinertia < 0) {
if(xinertia < 0)
{
if(xinertia+value > 0) xinertia = 0;
else xinertia += value;
}
else if(xinertia > 0) {
else if(xinertia > 0)
{
if(xinertia-value < 0) xinertia = 0;
else xinertia -= value;
}
}
// handles inertia and friction for the X direction
// (this is where the xinertia is actually applied to playx)
void CSpriteObject::InertiaAndFriction_X()
void CSpriteObject::InertiaAndFriction_X(const int friction_rate)
{
const int friction_rate = 10;
int dx=xinertia;
// check first if the player is not blocked
if( (!blockedr and dx>0) or (!blockedl and dx<0) )
......
......@@ -169,8 +169,8 @@ public:
*/
void processPushOutCollision();
void decreaseXInertia(const int& value);
void InertiaAndFriction_X();
void decreaseXInertia(const int value);
void InertiaAndFriction_X(const int friction_rate = 10);
virtual void process() { }
......
......@@ -382,7 +382,6 @@ void CPlayerLevel::processPogo()
xinertia = 0;
}
moveXDir(xinertia);
}
......
......@@ -15,7 +15,9 @@ namespace galaxy
const int A_EGG_NORMAL = 0;
const int A_EGG_BROKEN = 1;
const int A_EGG_SHELL = 2;
const int A_EGG_SHELL1 = 2;
const int A_EGG_SHELL2 = 3;
const int A_EGG_SHELL3 = 4;
CEgg::CEgg(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
......@@ -28,6 +30,30 @@ void CEgg::hatch()
{
setAction(A_EGG_BROKEN);
setActionSprite();
// Create
CEgg *shard1 = new CEgg( getMapPtr(), mFoeID, getXMidPos(), getYMidPos()-(8<<STC) );
CEgg *shard2 = new CEgg( getMapPtr(), mFoeID, getXMidPos(), getYMidPos()-(8<<STC) );
CEgg *shard3 = new CEgg( getMapPtr(), mFoeID, getXMidPos(), getYMidPos()-(8<<STC) );
shard1->xinertia = -70;
shard1->yinertia = -60;
shard2->xinertia = -100;
shard2->yinertia = -80;
shard3->xinertia = +60;
shard3->yinertia = -70;
shard1->setAction(A_EGG_SHELL1);
shard2->setAction(A_EGG_SHELL2);
shard3->setAction(A_EGG_SHELL3);
shard1->setActionSprite();
shard2->setActionSprite();
shard3->setActionSprite();
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard1 ) );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard2 ) );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( shard3 ) );
}
......@@ -58,8 +84,7 @@ void CEgg::process()
performCollisions();
//processActionRoutine();
InertiaAndFriction_X(3);
}
} /* namespace galaxy */
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