Permalink
Browse files

Documented max_t and updated Deprecated

  • Loading branch information...
1 parent f96c1f8 commit f60bc23167c584f418985f05ae5427c03c7ef303 @Blaizer Blaizer committed Apr 7, 2012
Showing with 16 additions and 7 deletions.
  1. +1 −5 lib/SDLx/Controller.pm
  2. +5 −1 lib/pods/SDL/Deprecated.pod
  3. +10 −1 lib/pods/SDLx/Controller.pod
View
@@ -38,7 +38,7 @@ sub new {
$_dt{ $ref } = defined $args{dt} ? $args{dt} : 0.1;
$_min_t{ $ref } = defined $args{min_t} ? $args{min_t} : 1 / 60;
- $_max_t{ $ref } = defined $args{max_t} ? $args{max_t} : 0.5;
+ $_max_t{ $ref } = defined $args{max_t} ? $args{max_t} : 0.1;
$_stop{ $ref } = 1;
$_event{ $ref } = $args{event} || SDL::Event->new();
$_event_handlers{ $ref } = $args{event_handlers} || [];
@@ -350,7 +350,3 @@ sub ticks {
}
1;
-
-__END__
-
-
@@ -22,7 +22,9 @@ SDLx::App had a full rewrite and SDLx::Controller was updated.
Shortcut aliases in the constructor have been changed and removed. The main ones people use are still there like
C<w>, C<h> and C<d>. These lesser used ones no longer work: C<t>, C<it>, C<i>, C<s>, C<ab>, C<db>, C<bs>, C<st>, C<asyncblit>.
-All OpenGL parameters for the constructor now have a C<gl_> prefix. These were never documented anyway,
+C<warp> was renamed to C<warp_cursor>, but this method wasn't documented before anyway.
+
+All OpenGL parameters for the constructor now have a C<gl_> prefix. These were never documented,
so they're not listed here.
The OpenGL method C<attribute> is now called C<gl_attribute>.
@@ -35,6 +37,8 @@ for backcompat.
The C<eoq> parameter and method have been removed. The exit on quit (stop on quit) action is now enabled by default.
The C<stop_handler> parameter and method are now used to change and disable the quit action of the app.
+C<max_t> will now slow the application down if it runs at less than 10 FPS, by default.
+
=back
=head2 2.517
@@ -58,6 +58,7 @@ such as pausing the game.
SDLx::Controller->new(
dt => 0.05,
min_t => 0,
+ max_t => 0.05,
delay => 1 / 200,
event_handlers => [ @event_callbacks ],
move_handlers => [ @move_callbacks ],
@@ -74,7 +75,7 @@ All params are optional and have sane defaults.
=item dt
-The length, in seconds, of a full movement step. Defaults to 0.1.
+The time, in seconds, of a full movement step. Defaults to 0.1.
In most cases, the C<dt> could be set to any number and the game could run almost identically
(except for floating-point precision differences). This is because B<the C<dt> is an enforcement of the maximum time
between calling movement handlers>. The actual time between calling move handlers may be much less, as the movement handlers
@@ -97,6 +98,14 @@ A C<min_t> of 1 / 60 ensures that the controller can update the screen at a maxi
A "V-Sync" such as this is necessary to prevent video "tear", which occurs when the app is updating faster than the monitor
can display. Setting it to 0, as seen above, will not delay the loop at all.
+=item max_t
+
+The maximum time, in seconds, that the movement handlers are allowed to handle in a single cycle of the run loop.
+If more time has passed since the last cycle, this time will not be handled and the game will slow down.
+This is to protect against the slippery slope effect that happens when lag causes more movement handlers to be called
+which, in turn, causes more lag. Setting C<max_t> to the same value as C<dt> guarantees that movement handlers will each
+only be called once per frame. Defaults to 0.1, meaning the game will slow down if it is running at lower than 10 FPS.
+
=item delay
The time, in seconds or milliseconds, to delay after every full L</run> loop. Defaults to 0.

0 comments on commit f60bc23

Please sign in to comment.