From: Dobrica Pavlinusic Date: Thu, 20 May 2010 15:00:15 +0000 (+0200) Subject: correctly center airplane X-Git-Url: http://git.rot13.org/?p=perl-landing-airplanes.git;a=commitdiff_plain;h=2123ea5b858e20104b075ce0d1bba95d1bd7c8a3;ds=sidebyside correctly center airplane --- diff --git a/Airplane.pm b/Airplane.pm index 0b49c85..0078cb4 100644 --- a/Airplane.pm +++ b/Airplane.pm @@ -36,10 +36,6 @@ sub draw { $self->{tick} = 0; return; } - my $to = SDL::Rect->new( - -x => $self->{path}[$pos], - -y => $self->{path}[$pos+1], - ); # $plane->blit( $plane->rect, $self->{app}, $to ); my $radian = atan2( @@ -52,6 +48,12 @@ sub draw { my $plane = SDL::Surface->new( -name => 'artwork/airplane.png' ); my $rotated = $tool->rotoZoom( $plane, $deg, 1, 1 ); + + my $to = SDL::Rect->new( + -x => $self->{path}[$pos] - $rotated->width / 2, + -y => $self->{path}[$pos+1] - $rotated->height / 2, + ); + $rotated->blit( $rotated->rect, $self->{app}, $to ); warn "$pos $radian $deg ", $rotated->width, ' ', $rotated->height;