summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;