diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-10-02 02:01:01 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2010-10-02 02:01:01 +0200 |
commit | 357d7bb484d65701952fdc63a2c30550baa46545 (patch) | |
tree | 9336a3a0ff4e5958f7309a7c59f89d2d1831077f /engine/engine.cpp | |
parent | 13135210973ac4254b4d6cbcb45fec0a7651276c (diff) |
Ported from SDL to SFML.
Diffstat (limited to 'engine/engine.cpp')
-rw-r--r-- | engine/engine.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/engine/engine.cpp b/engine/engine.cpp index eccf495..278007e 100644 --- a/engine/engine.cpp +++ b/engine/engine.cpp @@ -12,9 +12,9 @@ #include <boost/format.hpp> -void Engine::event_keypress(SDLKey key) { +void Engine::event_keypress(sf::Key::Code key) { switch(key) { - case SDLK_SPACE: + case sf::Key::Space: paused = !paused; break; default: @@ -84,13 +84,10 @@ void Engine::update() { glDisable(GL_TEXTURE_2D); glColor4f(1, 1, 0, 1); - unsigned int tick = SDL_GetTicks(); - if(tick - lastframes >= 1000) { - fps = (float)frames * ((float)(tick - lastframes) / 1000.0f); - frames = 1; - lastframes = tick; - } else { - frames++; + if(++fps_frames >= 60) { + fps = float(fps_frames) / fps_clock.GetElapsedTime(); + fps_clock.Reset(); + fps_frames = 0; } glScalef(0.0005, 0.0005, 0.0005); @@ -108,6 +105,4 @@ void Engine::update() { stage->draw(); glDisable(GL_SCISSOR_TEST); - - SDL_GL_SwapBuffers(); } |