Game Development with SDL and Perl
Upcoming SlideShare
Loading in...5
×
 

Game Development with SDL and Perl

on

  • 11,618 views

Over the past couple of years the SDL Perl bindings have gone through a complete rewrite, making them modular, stable, faster, multiplatform, 1:1 compatible with libsdl and fixing several memory leaks ...

Over the past couple of years the SDL Perl bindings have gone through a complete rewrite, making them modular, stable, faster, multiplatform, 1:1 compatible with libsdl and fixing several memory leaks while at it.

The community is more alive than ever and now the SDL Perl project is ready to move the Perl motto into gamedev:

"Simple games, easy. Complex games, possible."

In this talk I'll discuss some of the sugar layers being developed on top of SDL Perl, including game loops, widgets, physics engines and full-fledged frameworks for easy game development.

Statistics

Views

Total Views
11,618
Views on SlideShare
4,287
Embed Views
7,331

Actions

Likes
1
Downloads
35
Comments
0

53 Embeds 7,331

http://yapgh.blogspot.com 3199
http://yapgh.blogspot.de 682
http://yapgh.blogspot.co.uk 389
http://yapgh.blogspot.ca 385
http://yapgh.blogspot.fr 306
http://yapgh.blogspot.in 250
http://yapgh.blogspot.ru 216
http://yapgh.blogspot.com.br 168
http://yapgh.blogspot.com.au 145
http://yapgh.blogspot.jp 125
http://yapgh.blogspot.com.es 117
http://yapgh.blogspot.nl 106
http://yapgh.blogspot.kr 89
http://yapgh.blogspot.se 85
http://yapgh.blogspot.it 85
http://yapgh.blogspot.dk 78
http://yapgh.blogspot.co.at 69
http://yapgh.blogspot.co.il 68
http://yapgh.blogspot.cz 66
http://yapgh.blogspot.mx 56
http://yapgh.blogspot.ch 54
http://yapgh.blogspot.pt 52
http://yapgh.blogspot.hk 50
http://yapgh.blogspot.ie 49
http://yapgh.blogspot.fi 48
http://yapgh.blogspot.com.ar 45
http://yapgh.blogspot.hu 42
http://yapgh.blogspot.ro 41
http://yapgh.blogspot.no 35
http://yapgh.blogspot.gr 33
http://yapgh.blogspot.be 33
http://yapgh.blogspot.tw 30
http://yapgh.blogspot.co.nz 27
http://www.yapgh.blogspot.ru 27
http://yapgh.blogspot.sk 25
http://yapgh.blogspot.sg 15
http://translate.googleusercontent.com 9
http://feeds.churchturing.org 9
http://feeds.feedburner.com 6
http://yapgh.blogspot.com.tr 2
http://yapgh.blogspot.ae 2
http://www.yapgh.blogspot.co.uk 2
http://www.slashdocs.com 1
http://www.google.com.co 1
http://honyaku.yahoofs.jp 1
http://www.yapgh.blogspot.com 1
http://us-w1.rockmelt.com 1
https://www.google.de 1
http://webcache.googleusercontent.com 1
http://yapgh.blogspot.com&_=1384128000158 HTTP 1
More...

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Game Development with SDL and Perl Game Development with SDL and Perl Presentation Transcript

  • GameDevelopmentWith Perl and SDL - press start -
  • PerlSDL
  • PerlSDL
  • PerlSDL
  • Simple DirectMedia Layer
  • low level access
  • Video
  • Audio
  • Input Devices
  • cross-platform
  • Multimedia App libSDLDirectX GDI framebuffer Xlib Quartz ...MS Windows Linux OS X
  • LGPL v2
  • Round 1 . . . F IGH T !
  • 1:1 API
  • use strict;use warnings;use SDL;use SDL::Video;use SDL::Surface;use SDL::Rect;SDL::init(SDL_INIT_VIDEO);my ($screen_w, $screen_h) = (800, 600);my $screen = SDL::Video::set_video_mode( $screen_w, $screen_h, 32, SDL_ANYFORMAT);my $blue = SDL::Video::map_RGB($screen->format(), 0, 0, 255);SDL::Video::fill_rect( $screen, SDL::Rect->new(15, 15, 100, 100), $blue);SDL::Video::update_rect($screen, 0, 0, $screen_w, $screen_h);sleep 5; # so we have time to see!
  • Too low level
  • Not Perlish at all!
  • SDLx::* Sugar
  • use strict;use warnings;use SDLx::App;my $app = SDLx::App->new( width => 800, height => 600,);$app->draw_rect( [15, 15, 100, 100], # rect [0,0,255,255], # blue);$app->update;sleep 5; # so we have time to see!
  • The Game Loop
  • while ( $running ) { get_events(); update_game(); render_scene();}
  • while( $running ) { $loops = 0; while( get_tick_count() > $next_game_tick && $loops < $MAX_FRAMESKIP ) { get_events(); update_game(); $next_game_tick += $SKIP_TICKS; $loops++; } $interpolation = ( get_tick_count() + $SKIP_TICKS - $next_game_tick ) / $SKIP_TICKS; render_scene( $interpolation );}
  • SDLx::App->run;
  • use SDLx::App;my $app = SDLx::App->new;$app->add_move_handler( &update );$app->add_event_handler( &player_1 );$app->add_event_handler( &player_2 );$app->add_show_handler( &scene );$app->run;
  • Avenger
  • Avenger
  • sugary syntax
  • use Avenger title => My Game;update { ... };show { ... };event key_down => sub { ... };event mouse_left => sub { ... };start;
  • Box2Dintegration
  • use Avenger title => My Game;world->gravity( 0, -100 );my $player = world->create_dynamic( x => 30, y => 100 );my $floor = world->create_static( y => 50, w => app->w -100 , h => 10,);update { world->update };show { app->clear( [0, 0, 0, 255] ); app->draw_rect( $floor->rect, [0, 255, 0, 255] ); app->draw_rect( $player->rect, [255, 50, 0, 255] ); app->update;};start;
  • Simple games, easy.Complex games, possible!
  • use Avenger;use MyGame;start MainScreen;
  • package MyGame::MainScreen;use Avenger;load { ... };unload { ... };update { ... };event { ... };show { ... };1;
  • Other SDLx Goodies
  • my $menu = SDLx::Widget::Menu->new;$menu->items( New Game => sub { ... }, Load Game => sub { ... }, Options => sub { ... }, Quit => sub { ... },);show { $menu->render( app ) };
  • my $text = SDLx::Text->new( font => /path/to/my/font.ttf, color => white, h_align => center, shadow => 1, bold => 1,);$text->write_to( app, All your base are belong to us.);
  • my $music = SDLx::Music->new;$music->data( intro => { loops => 3, fade_in => 0.5, volume => 72, }, gameover => { finished => sub { print Done! }, },);$music->play( intro );
  • my $sprite = SDLx::Sprite::Animated->new;$sprite->load( hero.png )->start;show { $sprite->draw( app ) };
  • HUGE TODO LIST!
  • github.com/PerlGameDev #sdl (irc.perl.org)sdl-devel-subscribe@perl.org @SDLPerl
  • Thank YouFor Playing ! garu@cpan.org @garu_rj