1SDLx::FPS(3) User Contributed Perl Documentation SDLx::FPS(3)
2
3
4
6 SDLx::FPS - a more convenient way to set a framerate
7
9 use SDLx::FPS;
10 my $fps = SDLx::FPS->new(fps => 60);
11 while(1) { # Main game loop
12 # Do game related stuff
13
14 $fps->delay;
15 }
16
18 SDLx::FPS simplifies the task of giving your game a framerate.
19 Basically, it combines the methods of "SDL::GFX::Framerate" and
20 "SDL::GFX::FPSManager" into a single module. Use it to delay the main
21 loop to keep it at a specified framerate.
22
24 new
25 my $fps = SDLx::FPS->new( fps => 30 );
26
27 No arguments are required, if no "fps" is specified, the default FPS is
28 30.
29
30 set
31 $fps->set($new_framerate);
32
33 Same as "SDL::GFX::Framerate::set". Set the new desired framerate.
34
35 get
36 Same as "SDL::GFX::Framerate::get". Get the currently set framerate.
37
38 delay
39 Same as "SDL::GFX::Framerate::delay". Generate a delay to accommodate
40 currently set framerate. Call once in the graphics/rendering loop. If
41 the computer cannot keep up with the rate (i.e. drawing too slow), the
42 delay is 0 and the delay interpolation is reset.
43
44 framecount
45 Return the "framecount".
46
47 rateticks
48 Return the "rateticks".
49
50 lastticks
51 Return the "lastticks".
52
53 rate
54 Return the "rate".
55
57 See "AUTHORS" in SDL.
58
60 SDL::GFX::Framerate, SDL::GFX::FPSManager
61
62
63
64perl v5.28.0 2018-07-15 SDLx::FPS(3)