Skip to content

Commit

Permalink
Time physics explained, need to make example
Browse files Browse the repository at this point in the history
  • Loading branch information
kthakore committed Oct 9, 2010
1 parent 1f76232 commit be33c6f
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/04-game.pod
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,37 @@ animation speeds for different CPUs.

=head1 Integrating Physics

Looks goods
To solve the problem of the rendering being coupled with the CPU speed, we must derive our rendering and physics
for time. Objects moving according to real time will be consistent to all CPU, with proper interpolation. To be able
to perform interpolation we need 2 points that define the object. To achive these points we will use the real time
to get.

=head2 Problems
Our laser can be defined as having a behaviour of

X = Velocity * Change in Time, Y = 100

Which will give us points like, from time 0 to 20 secs:

1,100
5,100
10,100
20,100

Note that, at this point it doesn't matter at what CPU speed this equation is processed at the values are coupled to
real time. The only problem with this sort of solution is that for many objects and callbacks the implementation is non trivial,
and will not be explored in this book. However the implementation is made available from the C<SDLx::Controller> module we used before.

=head2 Laser in Real Time


use strict;
use warnings;
use SDL;
use SDLx::App;

but ok.

=head1 Learn More

To learn more about this topic please, see an excellent blog post by B<GafferOnGames.com>: L<http://gafferongames.com/game-physics/fix-your-timestep/>.

=for vim: spell

0 comments on commit be33c6f

Please sign in to comment.