5 # adapted from SDL-1.2.x/test/graywin.c
16 die <<USAGE if in($ARGV[0], qw/ -h --help -? /);
17 usage: $0 [-hw] [-fullscreen] [-width 640] [-height 480] [-bpp 24]
22 $options{$ARGV[$_]} = $ARGV[$_ + 1] || 1;
25 $options{-flags} = SDL_SWSURFACE;
26 $options{-flags} |= SDL_HWPALETTE if ( $options{-hw} );
27 $options{-flags} |= SDL_FULLSCREEN if ( $options{-fullscreen} );
29 $options{-title} = $0;
31 $options{-width} ||= 640;
32 $options{-height} ||= 480;
33 $options{-depth} ||= $options{-bpp} || 8;
35 my $app = new SDL::App %options;
40 my ($w, $h) = ( int(rand(640)), int(rand(480)) );
42 my $rect = new SDL::Rect -width => $w, -height => $h,
43 -x => ($x - int($w/2)), -y => ($y - int($h/2));
45 my $color = new SDL::Color -r => rand(256), -g => rand(256), -b => rand(256);
47 $app->fill($rect,$color);
52 SDL_MOUSEBUTTONDOWN() => sub {
54 DrawBox($event->button_x(),$event->button_y());
56 SDL_KEYDOWN() => sub {
58 $app->warp($options{-width}/2,$options{-height}/2)
59 if ($event->key_sym() == SDLK_SPACE);
61 if ($event->key_sym() == SDLK_f);
62 exit(0) if ($event->key_sym() == SDLK_ESCAPE);
64 SDL_QUIT() => sub { exit(0); }