diff --git a/PerlRPG/Assets.pm b/PerlRPG/Assets.pm index 5d4895a..7dfb793 100644 --- a/PerlRPG/Assets.pm +++ b/PerlRPG/Assets.pm @@ -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;