From 63f6c383942381cdf5547300e556eb148ef5fc7b Mon Sep 17 00:00:00 2001 From: Henrique Date: Thu, 25 Aug 2011 10:30:46 -0300 Subject: [PATCH] items animation --- src/otclient/core/item.cpp | 18 ++++++++++++++++-- src/otclient/core/item.h | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/otclient/core/item.cpp b/src/otclient/core/item.cpp index 76ea0a68..ff170817 100644 --- a/src/otclient/core/item.cpp +++ b/src/otclient/core/item.cpp @@ -2,17 +2,31 @@ #include "datmanager.h" #include "spritemanager.h" #include "thing.h" +#include 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() diff --git a/src/otclient/core/item.h b/src/otclient/core/item.h index d11ebc68..4541cdea 100644 --- a/src/otclient/core/item.h +++ b/src/otclient/core/item.h @@ -20,6 +20,8 @@ public: private: int m_count; + int m_lastTicks; + int m_animation; }; #endif