projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
simplify physic formula a bit
[supertux.git]
/
src
/
mainloop.cpp
diff --git
a/src/mainloop.cpp
b/src/mainloop.cpp
index
5f9230f
..
e5db024
100644
(file)
--- a/
src/mainloop.cpp
+++ b/
src/mainloop.cpp
@@
-49,7
+49,7
@@
static const int MAX_FRAME_SKIP = 2;
MainLoop* main_loop = NULL;
MainLoop::MainLoop()
MainLoop* main_loop = NULL;
MainLoop::MainLoop()
- : speed(1.0), nextpop(false), nextpush(false)
+ : speed(1.0), nextpop(false), nextpush(false)
, fps(0), screenshot_requested(false)
{
using namespace Scripting;
TimeScheduler::instance = new TimeScheduler();
{
using namespace Scripting;
TimeScheduler::instance = new TimeScheduler();
@@
-109,6
+109,12
@@
MainLoop::set_speed(float speed)
this->speed = speed;
}
this->speed = speed;
}
+float
+MainLoop::get_speed() const
+{
+ return speed;
+}
+
void
MainLoop::draw_fps(DrawingContext& context, float fps_fps)
{
void
MainLoop::draw_fps(DrawingContext& context, float fps_fps)
{
@@
-135,6
+141,11
@@
MainLoop::draw(DrawingContext& context)
if(config->show_fps)
draw_fps(context, fps);
if(config->show_fps)
draw_fps(context, fps);
+ // if a screenshot was requested, pass request on to drawing_context
+ if (screenshot_requested) {
+ context.take_screenshot();
+ screenshot_requested = false;
+ }
context.do_drawing();
/* Calculate frames per second */
context.do_drawing();
/* Calculate frames per second */
@@
-177,6
+188,9
@@
MainLoop::process_events()
config->use_fullscreen = !config->use_fullscreen;
init_video();
}
config->use_fullscreen = !config->use_fullscreen;
init_video();
}
+ else if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_PRINT) {
+ take_screenshot();
+ }
}
}
}
}
@@
-214,10
+228,8
@@
MainLoop::handle_screen_switch()
}
void
}
void
-MainLoop::run()
+MainLoop::run(
DrawingContext &context
)
{
{
- DrawingContext context;
-
Uint32 last_ticks = 0;
Uint32 elapsed_ticks = 0;
Uint32 last_ticks = 0;
Uint32 elapsed_ticks = 0;
@@
-262,3
+274,10
@@
MainLoop::run()
SDL_Delay(0);
}
}
SDL_Delay(0);
}
}
+
+void
+MainLoop::take_screenshot()
+{
+ screenshot_requested = true;
+}
+