SDL PerlBreno G. de Oliveira
SDL Perl?
SDL?
Simple DirectMedia Layer
● Interface para dispositivos...
... gráficos
... de audio
... de entrada
● Multiplataforma
● FOSS
SDL
Usado nas versões Linux de:
Unreal Tournament
Unreal TournamentCivilization: Call to Power
Doom 3
Soldier of Fortune
Descent³
Unreal TournamentCivilization: Call to Power
Descent³
Doom 3FreeSpace 2
Heretic II
Heroes of Might and Magic III
Myth II
Quake 4Shadowgrounds
Sid Meier's Alpha Centauri
Sim City 3000Soldier of Fortune
Unreal TournamentCivilization: Call to Power
Descent³
Doom 3
Enemy Territory: Quake Wars
FreeSpace 2
Heavy Metal: F.A.K.K.²
Heretic II
Heroes of Might and Magic III
Majesty: The Fantasy Kingdom Sim
Myth II
Quake 4
Rune
Rune: Halls of Valhalla
Shadowgrounds
Shadowgrounds: Survivor
Shogo: Mobile Armor Division
Sid Meier's Alpha Centauri
Sim City 3000
Simutrans
Soldier of Fortune
Usado em:
Usado em:
Usado em:
Usado em:
Usado em:
Arquitetura
Aplicativo Multimídia
Biblioteca SDL (libSDL)
DirectX GDI
Windows
framebuffer Xlib
Linux
Quartz
OS X
etc.
etc.
● Perl bindings para SDL
● API 1:1 com a libSDL (SDL::*)
● API açucarada (SDLx::*)
SDL Perl
Instalação
cpan> install SDL
Está vivo!use SDLx::App;SDLx::App>new>run;
Um pouco mais de controle
use SDLx::App;
my $app = SDLx::App>new( title => 'meu jogo', width => 200, height => 100,);
$app>run;
Um pouco mais de controle
Manipulando Eventos #1use SDL::Event;
sub on_event { my $event = shift; if ($event>type == SDL_QUIT) { return 0; }
return 1;}
$app>add_event_handler( \&on_event );
Game Loop
Eventos
Atualizações
Exibição
Exibindo... algo :)use SDL::Rect;
my $rect = SDL::Rect>new(10,10,10,10);
$app>add_show_handler( sub { $app>draw_rect([0,0,$app>w,$app>h],0xFFFFFFFF); $app>draw_rect($rect, 0xFF0000FF); $app>update;});
Manipulando Eventos #2sub on_event { my $event = shift; if ($event>type == SDL_QUIT) { return 0; }
return 1;}
Manipulando Eventos #2sub on_event { my $event = shift; if ($event>type == SDL_QUIT) { return 0; } elsif ($event>type == SDL_KEYDOWN) { given ($event>key_sym) { when (SDLK_LEFT ) { $rect>x( $rect>x 2 ) }; when (SDLK_RIGHT) { $rect>x( $rect>x + 2 ) }; when (SDLK_UP ) { $rect>y( $rect>y 2 ) }; when (SDLK_DOWN ) { $rect>y( $rect>y + 2 ) }; }; } return 1;}
Exemplos!
● Spinner
● Scroller
● Solitaire
● Zumbis
+Goodies● SDLx::Sprite
● SDLx::Sprite::Animated
● SDLx::Controller::Interface
● SDLx::Layers
● SDLx::Widgets::*
● "Jogo"
Mais informações
#sdl em irc.perl.org
sdl.perl.org
http://github.com/PerlGameDev/
Top Related