Add FlipSurface function

This commit is contained in:
Ryan Shepherd 2018-10-01 11:27:42 -04:00
parent feca9d5c11
commit e1d0817a5b
1 changed files with 14 additions and 0 deletions

View File

@ -268,4 +268,18 @@ sub LoadVirtualSprite {
return $anim;
}
# Flip surface left to right -- Returns new surface
sub FlipSurface {
my($surface) = @_;
my $new = SDLx::Surface->new( width => $surface->width(),
height => $surface->height(),
);
for(my $x=0; $x < $surface->width(); $x++) {
my $x2 = $surface->width() - $x - 1;
$surface->blit( [ $x, 0, 1, $surface->height() ], $new, [ $x2, 0, 1, $surface->height() ] );
}
return $new;
}
1;