# HG changeset patch # User spq@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1215786931 0 # Node ID 9a9f4447af7c3433564a97967914b34ce151f95b # Parent 9c3f37432a28ff66378df4e7b7ded532317617e1 add animation renderer diff -r 9c3f37432a28 -r 9a9f4447af7c engine/core/view/renderers/genericrenderer.cpp --- a/engine/core/view/renderers/genericrenderer.cpp Fri Jul 11 13:08:44 2008 +0000 +++ b/engine/core/view/renderers/genericrenderer.cpp Fri Jul 11 14:35:31 2008 +0000 @@ -36,6 +36,7 @@ #include "util/math/fife_math.h" #include "util/log/logger.h" #include "model/metamodel/grids/cellgrid.h" +#include "model/metamodel/timeprovider.h" #include "model/structures/instance.h" #include "model/structures/layer.h" #include "model/structures/location.h" @@ -244,10 +245,21 @@ GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode anchor, int animation): GenericRendererElementInfo(), m_anchor(anchor), - m_animation(animation) { + m_animation(animation), + m_start_time(SDL_GetTicks()), + m_time_scale(1.0) { } void GenericRendererAnimationInfo::render(Camera* cam, Layer* layer, std::vector& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { - return; + Point p = m_anchor.getCalculatedPoint(cam, layer, instances); + Animation& animation = animpool->getAnimation(m_animation); + int animtime = scaleTime(m_time_scale, SDL_GetTicks() - m_start_time) % animation.getDuration(); + Image* img = animation.getFrameByTimestamp(animtime); + Rect r; + r.x = p.x-img->getWidth()/2; + r.y = p.y-img->getHeight()/2; + r.w = img->getWidth(); + r.h = img->getHeight(); + img->render(r); } GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode anchor, AbstractFont* font, std::string text): diff -r 9c3f37432a28 -r 9a9f4447af7c engine/core/view/renderers/genericrenderer.h --- a/engine/core/view/renderers/genericrenderer.h Fri Jul 11 13:08:44 2008 +0000 +++ b/engine/core/view/renderers/genericrenderer.h Fri Jul 11 14:35:31 2008 +0000 @@ -135,6 +135,8 @@ private: GenericRendererNode m_anchor; int m_animation; + unsigned int m_start_time; + float m_time_scale; }; class GenericRendererTextInfo : public GenericRendererElementInfo { public: