SDL::Console - a SDL perl extension
use SDL::Console; my $console_rect= new SDL::Rect( -width =>$app->width, -height=>128 ); my $console = new SDL::Console( -surface => $app, -rect => $console_rect, -font => "ConsoleFont.bmp", -lines => 100, ); SDL::Console::addCommand("my_command", \&cmd_func); $console->topmost(); # gain focus while ($doStuffFlag) { # do normal event processing SDL::Console::event($event); # pass SDL::Event obj $console->draw; # blit console } sub cmd_func { my $console = shift; # SDL::Console object my $rawparams= shift; # original command line, not include command my @params =@_; # command line as indiviual args # (split ' ', $rawparams) $console->print("you called me with: $rawparams"); # print to the console }
The SDL::Console module encapsulates the SDL_Console library, and many of its ancillatory functions.
SDL::Console
Specifies the surface on which the console will be blitted. This method takes the following additional parameters:
-font the font file to use, default: "ConsoleFont.bmp"
-lines number of lines in the console, default: 32
-rect a SDL::Rect which specifies the console bounding box, default: x=0, y=0, w=surface width, height=25% of surface height
set the console alpha component (0-255)
load a background image
set the console origin
resize the console
class method to be called when events are processed.
class method to add a command to the Consoles repository
display the registered commands to the console & stdout
Wayne Keenan
perl(1) SDL::Surface(3) SDL::Rect(3) SDL::App(3) SDL::Event(3).
To install SDL_perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SDL_perl
CPAN shell
perl -MCPAN -e shell install SDL_perl
For more information on module installation, please visit the detailed CPAN module installation guide.