5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
38 $options{-flags} = SDL::SWSURFACE;
39 $options{-title} = $0;
40 $options{-width} ||= 640;
41 $options{-height} ||= 480;
42 $options{-depth} ||= $options{-bpp} || 8;
44 my $app = new SDL::App %options;
49 my ($w, $h) = ( int(rand(640)), int(rand(480)) );
51 my $rect = new SDL::Rect -width => $w, -height => $h,
52 -x => ($x - int($w/2)), -y => ($y - int($h/2));
54 my $color = new SDL::Color -r => rand(256), -g => rand(256), -b => rand(256);
56 $app->fill($rect,$color);
61 SDL_MOUSEBUTTONDOWN() => sub {
63 DrawBox($event->button_x(),$event->button_y());
65 SDL_KEYDOWN() => sub {
67 $app->warp($options{-width}/2,$options{-height}/2)
68 if ($event->key_sym() == SDLK_SPACE);
70 if ($event->key_sym() == SDLK_f);
71 exit(0) if ($event->key_sym() == SDLK_ESCAPE);
73 SDL_QUIT() => sub { exit(0); }