Hello perl monks, i am doing some game programming and am rewriting pong. I am heaving a problem with the horizontal alignment of text when i use the SDLx::Text module. I want the text to be centered, but it will only align to the left. I have made a short example program to reproduce the problem.
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;
I see only half the text and it is on the left side, not centered. I tried changing it to 'right', but this is also not working, this time i see no text at all. Only if you change it to 'left', or send no value at all it is correct, on the left-hand side. Could someone please tell me what is wrong with this pogram? Tx.