/examples/SDLx/app.pl

http://github.com/PerlGameDev/SDL · Perl · 21 lines · 12 code · 9 blank · 0 comment · 2 complexity · 3112191814415a1d5ee1abbdb0186637 MD5 · raw file

  1. use SDL::Event;
  2. use SDLx::App;
  3. my $app = SDLx::App->new(
  4. title => "Lines",
  5. width => 640,
  6. height => 480,
  7. );
  8. sub draw_lines { $app->draw_line( [ 0, 0 ], [ rand( $app->w ), rand( $app->h ) ], 0xFFFFFFFF ); $app->update(); }
  9. sub event_handle { my $e = shift; $_[0]->stop if ( $e->type == SDL_QUIT ); }
  10. $app->add_event_handler( \&event_handle );
  11. $app->add_show_handler( \&draw_lines );
  12. $app->run();