summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2010-05-17 18:03:07 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2010-05-17 18:03:07 +0200
commit59a1f2052cb3abef7cbc24f8f9fde3ebc0db2275 (patch)
tree30448aa049ac82eff2b43c71abc7f4e9b71cb208
parentf78606b6391b282426a73016fff9541320d4994b (diff)
Fixed pausing and broken event handling.
-rw-r--r--application.cpp19
-rw-r--r--application.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/application.cpp b/application.cpp
index 072c7a8..371ef2f 100644
--- a/application.cpp
+++ b/application.cpp
@@ -135,6 +135,7 @@ Application::~Application() {
void Application::run() {
elapsed = 0;
+ paused = false;
font = new FTPixmapFont("VeraMono.ttf");
font->FaceSize(12);
@@ -153,16 +154,18 @@ void Application::run() {
shader->attach(shader2);
shader->link();
- unsigned int lasttick = SDL_GetTicks();
+ lasttick = SDL_GetTicks();
while(1) {
SDL_Event event;
- SDL_PollEvent(&event);
- if(event.type == SDL_QUIT) {
- break;
- } else if(event.type == SDL_KEYDOWN) {
- event_keypress(event.key.keysym.sym);
+ while(SDL_PollEvent(&event)) {
+ if(event.type == SDL_QUIT) {
+ break;
+ } else if(event.type == SDL_KEYDOWN) {
+ event_keypress(event.key.keysym.sym);
+ }
}
+
if(please_quit) {
return;
}
@@ -280,6 +283,10 @@ void Application::event_keypress(SDLKey key) {
case SDLK_ESCAPE:
quit();
break;
+ case SDLK_SPACE:
+ paused = !paused;
+ lasttick = SDL_GetTicks();
+ break;
default:
break;
}
diff --git a/application.h b/application.h
index c9867b8..e40af07 100644
--- a/application.h
+++ b/application.h
@@ -15,6 +15,7 @@ class Application {
bool please_quit;
bool paused;
+ unsigned int lasttick;
unsigned int elapsed;
unsigned int frames;
unsigned int lastframes;