items animation

This commit is contained in:
Henrique 2011-08-25 10:30:46 -03:00
parent 9088bad0b0
commit 63f6c38394
2 changed files with 18 additions and 2 deletions

View File

@ -2,17 +2,31 @@
#include "datmanager.h"
#include "spritemanager.h"
#include "thing.h"
#include <framework/platform/platform.h>
Item::Item() : Thing(THING_ITEM)
{
m_count = 0;
m_lastTicks = g_platform.getTicks();
m_animation = 0;
}
void Item::draw(int x, int y)
{
const ThingAttributes& attributes = g_dat.getItemAttributes(m_id);
int xdiv = 0, ydiv = 0, zdiv = 0;
int xdiv = 0, ydiv = 0, zdiv = 0, anim = 0;
if(attributes.animcount > 1) {
if(g_platform.getTicks() - m_lastTicks > 500) {
if(m_animation+1 == attributes.animcount)
m_animation = 0;
else
m_animation++;
m_lastTicks = g_platform.getTicks();
}
}
if(attributes.group == THING_GROUP_SPLASH || attributes.group == THING_GROUP_FLUID) {
//xdiv = m_count % attributes.xdiv;
@ -48,7 +62,7 @@ void Item::draw(int x, int y)
}
for(int b = 0; b < attributes.blendframes; b++)
internalDraw(x, y, b, xdiv, ydiv, zdiv, anim);
internalDraw(x, y, b, xdiv, ydiv, zdiv, m_animation);
}
const ThingAttributes& Item::getAttributes()

View File

@ -20,6 +20,8 @@ public:
private:
int m_count;
int m_lastTicks;
int m_animation;
};
#endif