use strict; use warnings; use SDL; use SDLx::App; use SDL::Events; use SDLx::Rect; use SDLx::Text; my $app = SDLx::App->new(w =>500,h=>500,t=>"Pong",exit_on_quit=>1,dt=>0.02); my $player1={paddle=>SDLx::Rect->new(10,$app->h/2,10,40),v_y=>0,score=>0}; my $player2={paddle=>SDLx::Rect->new($app->w-20,$app->h/2,10,40),v_y=>0,score=>0}; my $ball = {rect => SDLx::Rect->new($app->w / 2, $app->h / 2, 10, 10),v_x=>-2.7,v_y=>1.2}; my $score = SDLx::Text->new(h_align=>'center'); $score->write_to($app,$player1->{score}.'x'.$player2->{score}); $app->update; $app->run;