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();
use SDL::SFont;
use SDL::Color;
use SDL::Rect;
-
+use Data::Dumper;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
if ($_[1] == 0 ) {
SDL::FillRect(${$_[0]},0,${$_[2]});
} else {
- SDL::FillRect(${$_[0]},${$_[1]},${$_[2]});
+ SDL::FillRect(${$_[0]},$_[1],${$_[2]});
}
}
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 {
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();
$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";
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)
-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;
$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();
}
{
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);
}