SDLx::FPS - a more convenient way to set a framerate
use SDLx::FPS; my $fps = SDLx::FPS->new(fps => 60); while(1) { # Main game loop # Do game related stuff $fps->delay; }
SDLx::FPS simplifies the task of giving your game a framerate. Basically, it combines the methods of SDL::GFX::Framerate and SDL::GFX::FPSManager into a single module. Use it to delay the main loop to keep it at a specified framerate.
SDL::GFX::Framerate
SDL::GFX::FPSManager
my $fps = SDLx::FPS->new( fps => 30 );
No arguments are required, if no fps is specified, the default FPS is 30.
fps
$fps->set($new_framerate);
Same as SDL::GFX::Framerate::set. Set the new desired framerate.
SDL::GFX::Framerate::set
Same as SDL::GFX::Framerate::get. Get the currently set framerate.
SDL::GFX::Framerate::get
Same as SDL::GFX::Framerate::delay. Generate a delay to accommodate currently set framerate. Call once in the graphics/rendering loop. If the computer cannot keep up with the rate (i.e. drawing too slow), the delay is 0 and the delay interpolation is reset.
SDL::GFX::Framerate::delay
Return the framecount.
framecount
Return the rateticks.
rateticks
Return the lastticks.
lastticks
Return the rate.
rate
See "AUTHORS" in SDL.
SDL::GFX::Framerate, SDL::GFX::FPSManager
To install SDL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL
CPAN shell
perl -MCPAN -e shell install SDL
For more information on module installation, please visit the detailed CPAN module installation guide.