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::Framerate
  • SDL::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