use FindBin qw($Bin); chdir($Bin); use lib $FindBin::Bin . '/LIBS'; use SimpleButton; #in zusätzlichen sub dir "X", daher X:: my $SimpleButton = SimpleButton->new(); use SDL; use SDL::App; use SDL::Event; use SDL::Surface; use SDL::Color; use SDL::Rect; my $app = SDL::App->new( -width => 900, -height => 600, -depth => 16, ); my $img = SDL::Surface->new( -name => 'x.png' ); my $img2 = SDL::Surface->new( -name => 'x_on.png' ); for my $i (0..10) { for my $x (0..7) { $SimpleButton = SimpleButton->new(); $id++; $SimpleButton->add_Butt($id,$app,(105*$x),(45*$i),$img,$img2); push(@butts,$SimpleButton); } } $event = new SDL::Event(); while(1) { # process event queue $event->pump; $event->poll; my $etype=$event->type; # handle user events last if ($etype eq SDL_QUIT ); last if (SDL::GetKeyState(SDLK_ESCAPE)); for(@butts) { my $click = $_->check($event->button_x,$event->button_y,$event); if($click ne 0 ) {print "\r ",$click," ";} } }