From: Kartik Thakore Date: Sun, 13 Sep 2009 00:31:09 +0000 (-0400) Subject: More fixes, some clean up. For some reason blit is not work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=43a05747be5e7eff8cdc93e23914962f263098d9;p=sdlgit%2FSDL_perl.git More fixes, some clean up. For some reason blit is not work --- diff --git a/lib/SDL/Game/Rect.pm b/lib/SDL/Game/Rect.pm index 7d443ae..66d7baa 100644 --- a/lib/SDL/Game/Rect.pm +++ b/lib/SDL/Game/Rect.pm @@ -13,7 +13,7 @@ sub new { my $w = shift || 0; my $h = shift || 0; - my $self = SDL::Rect->new($x, $y, $w, $h); + my $self = $class->SUPER::new($x, $y, $w, $h); unless ($$self) { require Carp; Carp::croak SDL::GetError(); diff --git a/lib/SDL/Surface.pm b/lib/SDL/Surface.pm index d0a53d6..5ba31f6 100644 --- a/lib/SDL/Surface.pm +++ b/lib/SDL/Surface.pm @@ -37,7 +37,7 @@ use SDL; use SDL::SFont; use SDL::Color; use SDL::Rect; - +use Data::Dumper; sub new { my $proto = shift; my $class = ref($proto) || $proto; @@ -166,7 +166,7 @@ sub fill { if ($_[1] == 0 ) { SDL::FillRect(${$_[0]},0,${$_[2]}); } else { - SDL::FillRect(${$_[0]},${$_[1]},${$_[2]}); + SDL::FillRect(${$_[0]},$_[1],${$_[2]}); } } @@ -208,7 +208,7 @@ sub blit { croak "SDL::Surface::blit requires SDL::Surface objects" unless $_[2]->isa('SDL::Surface'); } - SDL::BlitSurface(map { (defined($_) && $_ != 0)? ${$_} : $_ } @_) if defined(@_); + SDL::BlitSurface( $_[0], $_[1], ${$_[2]}, $_[3]); } sub set_colors { diff --git a/src/Rect.xs b/src/Rect.xs index ef4d471..cde0b7a 100644 --- a/src/Rect.xs +++ b/src/Rect.xs @@ -83,7 +83,7 @@ void rect_DESTROY(self) SDL_Rect *self CODE: - printf("RectPtr::DESTROY\n"); + safefree( (char *)self ); diff --git a/t/extendingrect.t b/t/extendingrect.t index e6733c6..f27ab52 100644 --- a/t/extendingrect.t +++ b/t/extendingrect.t @@ -7,7 +7,7 @@ sub new { my $y = shift || 0; my $w = shift || 0; my $h = shift || 0; - my $self = SDL::Rect->new($x, $y, $w, $h); + my $self = $class->SUPER::new($x, $y, $w, $h); unless ($$self) { require Carp; Carp::croak SDL::GetError(); diff --git a/test/testcolor.pl b/test/testcolor.pl index 9865b62..e341a85 100644 --- a/test/testcolor.pl +++ b/test/testcolor.pl @@ -25,8 +25,7 @@ my %colors = ( $x = 0; $y = 0; -$rect = new SDL::Rect -x => $x, -y => $y, - -w => $app->width / scalar(keys %colors), -h => $app->height(); +$rect = SDL::Rect->new( $x, $y, $app->width / scalar(keys %colors), $app->height()); print "Sorted colors:\n"; diff --git a/test/testsprite.pl b/test/testsprite.pl index 7559942..5de16ff 100644 --- a/test/testsprite.pl +++ b/test/testsprite.pl @@ -17,6 +17,8 @@ use SDL::Surface; use SDL::Color; use SDL::Rect; +#use base "../"; + use vars qw/ $app $app_rect $background $event $sprite $sprite_rect $videoflags /; ## User tweakable settings (via cmd-line) @@ -70,9 +72,9 @@ sub init_game_context -flags => $videoflags, ); - $app_rect= new SDL::Rect( - -height => $settings{screen_height}, - -width => $settings{screen_width}, + $app_rect= SDL::Rect->new(0,0, + $settings{screen_height}, + $settings{screen_width} ); $background = $SDL::Color::black; @@ -86,11 +88,7 @@ sub init_game_context $sprite->set_color_key(SDL_SRCCOLORKEY,$sprite->pixel(0,0)); # sets the transparent color to that at (0,0) - $sprite_rect = new SDL::Rect(-x => 0, - -y => 0, - -width => $sprite->width, - -height=> $sprite->height, - ); + $sprite_rect = SDL::Rect->new(0, 0, $sprite->width, $sprite->height); $event = new SDL::Event(); } @@ -135,11 +133,7 @@ sub put_sprite { my ($x,$y) = @_; - my $dest_rect = new SDL::Rect(-x => $x, - -y => $y, - -width => $sprite->width, - -height => $sprite->height, - ); + my $dest_rect = SDL::Rect->new($x, $y, $sprite->width, $sprite->height); $sprite->blit($sprite_rect, $app, $dest_rect); }