fix animation for good this time
[exterlulz-musk.git] / src / main.cpp
blob3ad7ded445a8ec62b78e326af778850d9adce060
1 #include <SDL/SDL.h>
3 #include "musk/engine.h"
4 #include "musk/scene.h"
5 #include "musk/image.h"
6 #include "musk/animation.h"
7 #include "musk/timer.h"
9 // TODO: Find a way to copy the SDL framework AND the resources
11 int main(int argc, char **argv)
13 using musk::Engine;
14 using musk::Scene;
15 using musk::Image;
16 using musk::Animation;
17 using musk::Actor;
18 using musk::Timer;
20 Engine engine("../resources/main.lua");
21 engine.boot();
23 Scene scene(Image("../resources/background.png"));
25 Actor hero(Animation("../resources/hero.png", 2));
26 hero.setPosition(4, 24);
27 scene.addActor(hero);
29 uint32_t fps = engine.fps();
30 Timer timer;
32 bool quit = false;
33 SDL_Event event;
35 while (quit == false) {
36 timer.reset();
38 // TODO: let the engine handle the events
39 while (SDL_PollEvent(&event) == 1) {
40 if (event.type == SDL_QUIT) {
41 quit = true;
42 break;
45 if (quit == true) {
46 break; // TODO: or save the game?
49 scene.draw(engine.screen());
51 if (timer.ticks() < (1000.0 / fps)) {
52 SDL_Delay((1000.0 / fps) - timer.ticks());
55 scene.step(timer.ticks());
58 return 0;