SDLx::FPS(3pm)
π SDLx::FPS(3pm) β a more convenient way to set a framerate π
okay bestie, this is the SDLx::FPS manual page, and it's literally here to make framerates less of a whole thing. Let's get into it β¨
π NAME π
SDLx::FPS β a more convenient way to set a framerate. That's the whole name, no cap π
β¨ SYNOPSIS β¨
use SDLx::FPS;
my $fps = SDLx::FPS->new(fps => 60);
while(1) { # Main game loop
# Do game related stuff
$fps->delay;
}
π¦ DESCRIPTION π¦
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. It's giving "one module to rule the loop" and honestly? Obsessed π«Ά
π METHODS π
πΈ new
my $fps = SDLx::FPS->new( fps => 30 );
No arguments are required. If no fps is specified, the default FPS is 30. So yeah, you can just vibe in with no setup and it'll still work π
β set
$fps->set($new_framerate);
Same as SDL::GFX::Framerate::set. Set the new desired framerate. New rate, who dis? β¨
π get
Same as SDL::GFX::Framerate::get. Get the currently set framerate. Very "tell me what we're working with" energy π
π₯ delay
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. So if your machine is lowkey struggling, it says "no delay bestie" and resets the interpolation β important lore π
π framecount
Return the framecount. That's it, that's the method π¦
π rateticks
Return the rateticks. Cute name, useful number, we love to see it π
π§ lastticks
Return the lastticks. It's right there in the name, bestie β¨
π rate
Return the rate. The rate is rate-ing, periodt π
π AUTHORS π
See AUTHORS in SDL. Gotta credit the icons behind the icons π
π SEE ALSO π
SDL::GFX::FramerateSDL::GFX::FPSManager
π Cute little sign-off: this page is from perl v5.42.0, dated 2024-05-01, and it's the SDLx::FPS(3pm) manual β mwah! π
π¦ where this page comes from
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms