fix animation timing
[exterlulz-musk.git] / src / musk / scene.cpp
blob6e41d26d6df80a4d86f0a660ede4db48b57a7ea4
1 #include "scene.h"
3 #include <SDL/SDL.h>
5 namespace musk {
7 using std::list;
9 Scene::Scene(const Image& background) :
10 background_(background),
11 animations_() {
14 void Scene::setBackground(const Image& background) {
15 background_ = background;
18 void Scene::addAnimation(const Animation& animation) {
19 animations_.push_back(animation);
22 void Scene::addActor(const Actor& actor) {
23 actors_.push_back(actor);
26 void Scene::draw(SDL_Surface *dest, uint32_t ticks)
28 background_.draw(dest);
30 // draw the animations
31 for (list<Animation>::iterator iter = animations_.begin();
32 iter != animations_.end();
33 iter++) {
34 Animation& animation = *iter;
36 animation.draw(dest);
37 animation.step(ticks);
40 // draw the actors
41 for (list<Actor>::iterator iter = actors_.begin();
42 iter != actors_.end();
43 iter++) {
44 Actor& actor = *iter;
46 actor.move();
47 actor.draw(dest);
48 actor.step(ticks);
51 SDL_Flip(dest);
53 } // namespace musk