From 2123ea5b858e20104b075ce0d1bba95d1bd7c8a3 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 20 May 2010 17:00:15 +0200 Subject: [PATCH] correctly center airplane --- Airplane.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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; -- 2.20.1