SDL::App::FPS 0.21 review
Download
|
|
SDL::App::FPS is a framework for event-driven SDL games/applications.
SYNOPSIS
Subclass SDL::App::FPS and override some methods:
package SDL::App::MyFPS;
use strict;
use SDL::App::FPS;
use SDL;
use base qw/SDL::App::FPS/;
# override the method draw_frame with something to draw
sub draw_frame
{
my ($self,$current_time,$lastframe_time,$current_fps) = @_;
...
}
# override post_init_handler and add some event handlers
sub post_init_handler
{
my ($self} = shift;
my $self->add_event_handler(SDL_KEYDOWN, SDLK_q, sub
{
my $self = shift; $self->quit();
} );
# or easier for often-used events (note quoted 'SDLK_f'!)
$self->watch_event( fullscreen => 'SDLK_f', pause => 'p',
quit => 'SDLK_q',
);
# You can also specify the key/mousebutton bindings for these events
# in the config file like "bind_event_fullscreen = f"
}
Then write a small script using SDL::App::MyFPS like this:
#!/usr/bin/perl -w
use strict;
use SDL::App::MyFPS;
# fill in here default options if you like
my $options = { };
# create a new application including window
# automatically uses a config file or the command line:
my $app = SDL::App::MyFPS->new( $options );
# run the application, will exit when done
$app->main_loop();
That's all!
Requirements:
Perl
SDL::App::FPS 0.21 search tags