Mercurial > fife-parpg
comparison engine/core/view/renderers/genericrenderer.cpp @ 31:9a9f4447af7c
add animation renderer
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 11 Jul 2008 14:35:31 +0000 |
parents | 9c3f37432a28 |
children | 75b6394ced14 |
comparison
equal
deleted
inserted
replaced
30:9c3f37432a28 | 31:9a9f4447af7c |
---|---|
34 #include "video/fonts/abstractfont.h" | 34 #include "video/fonts/abstractfont.h" |
35 #include "video/image.h" | 35 #include "video/image.h" |
36 #include "util/math/fife_math.h" | 36 #include "util/math/fife_math.h" |
37 #include "util/log/logger.h" | 37 #include "util/log/logger.h" |
38 #include "model/metamodel/grids/cellgrid.h" | 38 #include "model/metamodel/grids/cellgrid.h" |
39 #include "model/metamodel/timeprovider.h" | |
39 #include "model/structures/instance.h" | 40 #include "model/structures/instance.h" |
40 #include "model/structures/layer.h" | 41 #include "model/structures/layer.h" |
41 #include "model/structures/location.h" | 42 #include "model/structures/location.h" |
42 | 43 |
43 #include "view/camera.h" | 44 #include "view/camera.h" |
242 } | 243 } |
243 | 244 |
244 GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode anchor, int animation): | 245 GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode anchor, int animation): |
245 GenericRendererElementInfo(), | 246 GenericRendererElementInfo(), |
246 m_anchor(anchor), | 247 m_anchor(anchor), |
247 m_animation(animation) { | 248 m_animation(animation), |
249 m_start_time(SDL_GetTicks()), | |
250 m_time_scale(1.0) { | |
248 } | 251 } |
249 void GenericRendererAnimationInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { | 252 void GenericRendererAnimationInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { |
250 return; | 253 Point p = m_anchor.getCalculatedPoint(cam, layer, instances); |
254 Animation& animation = animpool->getAnimation(m_animation); | |
255 int animtime = scaleTime(m_time_scale, SDL_GetTicks() - m_start_time) % animation.getDuration(); | |
256 Image* img = animation.getFrameByTimestamp(animtime); | |
257 Rect r; | |
258 r.x = p.x-img->getWidth()/2; | |
259 r.y = p.y-img->getHeight()/2; | |
260 r.w = img->getWidth(); | |
261 r.h = img->getHeight(); | |
262 img->render(r); | |
251 } | 263 } |
252 | 264 |
253 GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode anchor, AbstractFont* font, std::string text): | 265 GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode anchor, AbstractFont* font, std::string text): |
254 GenericRendererElementInfo(), | 266 GenericRendererElementInfo(), |
255 m_anchor(anchor), | 267 m_anchor(anchor), |