CItemEffect.cpp 1.28 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*
 * CItemEffect.cpp
 *
 *  Created on: 19.11.2010
 *      Author: gerstrong
 *
 *  This will animate the picked up items. It's basically the same
 *  as CRisingPoints in the Vorticon Engine.
 *  Here we have different cases, because some animations differ
 */

#include "CItemEffect.h"

namespace galaxy {

const int itemEffectTime = 50;
17
const int itemEffectTime_Animation = 14;
18

19
CItemEffect::CItemEffect(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, Uint16 l_sprite, item_effect_type ieffect) :
20
CGalaxySpriteObject(pmap, foeID, x, y, 0)
21 22 23 24 25
{
	m_timer = 0;
	sprite = l_sprite-124;
	honorPriority = false;
	solid = false;
26
	m_ieffect = ieffect;
Gerhard Stein's avatar
Gerhard Stein committed
27
			
28
    GsSprite &rSprite = gGraphics.getSprite(mSprVar,sprite);
Gerhard Stein's avatar
Gerhard Stein committed
29 30 31 32 33

	int moveup = (1<<CSF)-1;
	moveup -= ((rSprite.getHeight()+1)<<STC);
	m_Pos.y += moveup;
	processMove(0, 1);
34 35 36
}

void CItemEffect::process()
Gerhard Stein's avatar
Gerhard Stein committed
37
{    
38 39 40 41 42 43 44
	if(m_ieffect == FLOAT)
	{
		if(m_timer >= itemEffectTime)
			exists = false;

		moveUp(16);
	}
Gerhard Stein's avatar
Gerhard Stein committed
45 46 47 48
	else if(m_ieffect == FADEOUT)
	{
		if(m_timer >= itemEffectTime)
		{
Gerhard Stein's avatar
Gerhard Stein committed
49
		    transluceny += 20;
Gerhard Stein's avatar
Gerhard Stein committed
50

Gerhard Stein's avatar
Gerhard Stein committed
51
		    if(transluceny >= 240)
Gerhard Stein's avatar
Gerhard Stein committed
52 53 54 55 56 57 58 59
		    {
			    exists = false;
			    return;
		    }
		}

		moveUp(16);
	}	
60 61 62 63 64 65 66 67
	else if(m_ieffect == ANIMATE)
	{
		if(m_timer >= itemEffectTime_Animation)
			exists = false;

		if((m_timer%6) == 5)
			sprite++;
	}
68 69 70 71 72

	m_timer++;
}

}