Permalink
Browse files

Using cluck and confess now. Perltidied too

  • Loading branch information...
1 parent ed53242 commit c33c98118315a59da6eb7803f4ca1f8ecf267446 @kthakore kthakore committed Sep 10, 2010
@@ -91,6 +91,7 @@ sub init {
sub on_move {
my $dt = shift;
+
#$dt = $dt / 1000;
paddle_confine( $paddle, $dt, $app->h );
paddle_confine( $paddle2, $dt, $app->h );
View
@@ -42,7 +42,7 @@ sub new {
my $self;
if ( $options{-from} ) {
- croak "SDL::MPEG::new -from requires a SDL::Video object\n"
+ Carp::confess "SDL::MPEG::new -from requires a SDL::Video object\n"
unless $options{-from}->isa('SDL::Video');
$self = \SDL::SMPEGGetInfo( ${ $options{-from} } );
View
@@ -19,7 +19,7 @@ sub new {
my $info = SDL::MPEG->new();
my $self = \SDL::NewSMPEG( $n, $$info, $a );
- croak SDL::GetError() unless $$self;
+ Carp::confess SDL::GetError() unless $$self;
bless $self, $class;
$self->audio(1);
$self->video(1);
@@ -47,7 +47,7 @@ sub volume {
}
sub display {
- croak "SDL::SMPEG::Display requires a SDL::Surface\n"
+ Carp::confess "SDL::SMPEG::Display requires a SDL::Surface\n"
unless $_[1]->isa('SDL::Surface');
SDL::SMPEGSetDisplay( ${ $_[0] }, ${ $_[1] }, 0 );
}
@@ -88,7 +88,7 @@ sub loop {
}
sub region {
- croak "SDL::SMPEG::region requires a SDL::Rect\n"
+ Carp::confess "SDL::SMPEG::region requires a SDL::Rect\n"
unless $_[1]->isa('SDL::Rect');
SDL::SMPEGDisplayRegion( ${ $_[0] }, ${ $_[1] } );
}
View
@@ -52,15 +52,15 @@ sub new {
$self->{-fg} = $options{-foreground} || $options{-fg} || $SDL::Color::black;
$self->{-bg} = $options{-background} || $options{-bg} || $SDL::Color::white;
- croak "SDL::TTFont::new requires a -name\n"
+ Carp::confess "SDL::TTFont::new requires a -name\n"
unless ( $$self{-name} );
- croak "SDL::TTFont::new requires a -size\n"
+ Carp::confess "SDL::TTFont::new requires a -size\n"
unless ( $$self{-size} );
$self->{-font} = SDL::TTFOpenFont( $self->{-name}, $self->{-size} );
- croak "Could not open font $$self{-name}, ", SDL::GetError(), "\n"
+ Carp::confess "Could not open font $$self{-name}, ", SDL::GetError(), "\n"
unless ( $self->{-font} );
bless $self, $class;
@@ -76,7 +76,7 @@ sub DESTROY {
sub print {
my ( $self, $surface, $x, $y, @text ) = @_;
- croak "Print requies an SDL::Surface"
+ Carp::confess "Print requies an SDL::Surface"
unless ( ref($surface) && $surface->isa("SDL::Surface") );
SDL::FreeSurface( $self->{-surface} ) if ( $$self{-surface} );
@@ -86,7 +86,7 @@ sub print {
$self->{-fg}, $self->{-bg}, join( "", @text )
);
- croak "Could not print \"", join( "", @text ), "\" to surface, ", SDL::GetError(), "\n"
+ Carp::confess "Could not print \"", join( "", @text ), "\" to surface, ", SDL::GetError(), "\n"
unless ( $$self{-surface} );
}
@@ -177,7 +177,7 @@ sub unicode_blended {
$$self{-mode} = SDL::UNICODE_BLENDED();
}
-croak "Could not initialize True Type Fonts\n"
+Carp::confess "Could not initialize True Type Fonts\n"
if ( SDL::TTFInit() < 0 );
1;
View
@@ -106,7 +106,7 @@ sub new {
}
my $surface = SDL::Video::set_video_mode( $w, $h, $d, $f )
- or croak SDL::get_error();
+ or Carp::confess SDL::get_error();
$options{surface} = $surface;
my $self = SDLx::Surface->new(%options);
@@ -195,7 +195,7 @@ sub attribute {
SDL::Video::GL_set_attribute( $mode, $value );
}
my $returns = SDL::Video::GL_get_attribute($mode);
- croak "SDLx::App::attribute failed to get GL attribute"
+ Carp::confess "SDLx::App::attribute failed to get GL attribute"
if ( $$returns[0] < 0 );
$$returns[1];
}
@@ -123,7 +123,8 @@ sub add_move_handler {
}
sub add_event_handler {
- Carp::confess 'SDLx::App or a Display (SDL::Video::get_video_mode) must be made' unless SDL::Video::get_video_surface();
+ Carp::confess 'SDLx::App or a Display (SDL::Video::get_video_mode) must be made'
+ unless SDL::Video::get_video_surface();
$_[0]->remove_all_event_handlers if !$_event_handlers{ refaddr $_[0] };
return _add_handler( $_event_handlers{ refaddr $_[0] }, $_[1] );
}
@@ -142,7 +143,7 @@ sub _remove_handler {
} 0 .. $#{$handlers_ref}
)[0]; #only the first coderef
if ( !defined $id ) {
- Carp::carp("$id is not currently a handler of this type");
+ Carp::cluck("$id is not currently a handler of this type");
return;
}
}
View
@@ -10,7 +10,7 @@ sub new {
if ( ref $args[0] ) {
my %options = %{ $args[0] };
if ( @args > 1 ) {
- Carp::carp("Extra arguments are not taken when hash is specified");
+ Carp::cluck("Extra arguments are not taken when hash is specified");
}
for (
grep {
@@ -19,11 +19,11 @@ sub new {
} keys %options
)
{
- Carp::carp("Unrecognized constructor hash key: $_");
+ Carp::cluck("Unrecognized constructor hash key: $_");
}
@args = ( @options{qw/fps framecount rateticks lastticks rate/} );
} elsif ( @args > 4 ) {
- Carp::carp("Too many arguments given");
+ Carp::cluck("Too many arguments given");
}
my $fps = $class->SDL::GFX::FPSManager::new(
map defined() ? $_ : 0,
View
@@ -17,7 +17,7 @@ sub new {
unless ($$self) {
#require Carp;
- croak SDL::get_error();
+ Carp::confess SDL::get_error();
}
bless $self, $class;
return $self;
@@ -266,7 +266,7 @@ sub move {
if ( not defined $x or not defined $y ) {
#require Carp;
- croak "must receive x and y positions as argument";
+ Carp::confess "must receive x and y positions as argument";
}
return $self->new(
-top => $self->top + $y,
@@ -281,7 +281,7 @@ sub move_ip {
if ( not defined $x or not defined $y ) {
#require Carp;
- croak "must receive x and y positions as argument";
+ Carp::confess "must receive x and y positions as argument";
}
$self->x( $self->x + $x );
$self->y( $self->y + $y );
@@ -294,7 +294,7 @@ sub inflate {
if ( not defined $x or not defined $y ) {
#require Carp;
- croak "must receive x and y positions as argument";
+ Carp::confess "must receive x and y positions as argument";
}
return $self->new(
@@ -310,7 +310,7 @@ sub inflate_ip {
if ( not defined $x or not defined $y ) {
#require Carp;
- croak "must receive x and y positions as argument";
+ Carp::confess "must receive x and y positions as argument";
}
$self->x( $self->x - ( $x / 2 ) );
@@ -338,7 +338,7 @@ sub clamp {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my $x = _get_clamp_coordinates( $self->x, $self->w, $rect->x, $rect->w );
@@ -351,7 +351,7 @@ sub clamp_ip {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my $x = _get_clamp_coordinates( $self->x, $self->w, $rect->x, $rect->w );
@@ -433,7 +433,7 @@ sub clip {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _get_intersection_coordinates( $self, $rect );
@@ -445,7 +445,7 @@ sub clip_ip {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _get_intersection_coordinates( $self, $rect );
@@ -482,7 +482,7 @@ sub union {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _test_union( $self, $rect );
@@ -493,7 +493,7 @@ sub union_ip {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _test_union( $self, $rect );
@@ -520,7 +520,7 @@ sub _test_unionall {
# TODO: better error message, maybe saying which item
# is the bad one (by list position)
- croak "must receive an array reference of SDL::Rect-based objects";
+ Carp::confess "must receive an array reference of SDL::Rect-based objects";
}
$left = $rect->x if $rect->x < $left; # MIN
@@ -538,7 +538,7 @@ sub unionall {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'ARRAY' ) {
- croak "must receive an array reference of SDL::Rect-based objects";
+ Carp::confess "must receive an array reference of SDL::Rect-based objects";
}
my ( $x, $y, $w, $h ) = _test_unionall( $self, $rects );
@@ -550,7 +550,7 @@ sub unionall_ip {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'ARRAY' ) {
- croak "must receive an array reference of SDL::Rect-based objects";
+ Carp::confess "must receive an array reference of SDL::Rect-based objects";
}
my ( $x, $y, $w, $h ) = _test_unionall( $self, $rects );
@@ -583,7 +583,7 @@ sub fit {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _check_fit( $self, $rect );
@@ -595,7 +595,7 @@ sub fit_ip {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my ( $x, $y, $w, $h ) = _check_fit( $self, $rect );
@@ -627,7 +627,7 @@ sub contains {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
my $contained =
@@ -645,7 +645,7 @@ sub collidepoint {
my ( $self, $x, $y ) = (@_);
unless ( defined $x and defined $y ) {
- croak "must receive (x,y) as arguments";
+ Carp::confess "must receive (x,y) as arguments";
}
my $inside =
@@ -672,7 +672,7 @@ sub colliderect {
my ( $self, $rect ) = (@_);
unless ( $rect->isa('SDL::Rect') ) {
- croak "must receive an SDL::Rect-based object";
+ Carp::confess "must receive an SDL::Rect-based object";
}
return _do_rects_intersect( $self, $rect );
@@ -682,7 +682,7 @@ sub collidelist {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'ARRAY' ) {
- croak "must receive an array reference of SDL::Rect-based objects";
+ Carp::confess "must receive an array reference of SDL::Rect-based objects";
}
for ( my $i = 0; $i < @{$rects}; $i++ ) {
@@ -697,7 +697,7 @@ sub collidelistall {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'ARRAY' ) {
- croak "must receive an array reference of SDL::Rect-based objects";
+ Carp::confess "must receive an array reference of SDL::Rect-based objects";
}
my @collisions = ();
@@ -713,12 +713,12 @@ sub collidehash {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'HASH' ) {
- croak "must receive an hash reference of SDL::Rect-based objects";
+ Carp::confess "must receive an hash reference of SDL::Rect-based objects";
}
while ( my ( $key, $value ) = each %{$rects} ) {
unless ( $value->isa('SDL::Rect') ) {
- croak "hash element of key '$key' is not an SDL::Rect-based object";
+ Carp::confess "hash element of key '$key' is not an SDL::Rect-based object";
}
if ( _do_rects_intersect( $self, $value ) ) {
@@ -732,13 +732,13 @@ sub collidehashall {
my ( $self, $rects ) = (@_);
unless ( defined $rects and ref $rects eq 'HASH' ) {
- croak "must receive an hash reference of SDL::Rect-based objects";
+ Carp::confess "must receive an hash reference of SDL::Rect-based objects";
}
my %collisions = ();
while ( my ( $key, $value ) = each %{$rects} ) {
unless ( $value->isa('SDL::Rect') ) {
- croak "hash element of key '$key' is not an SDL::Rect-based object";
+ Carp::confess "hash element of key '$key' is not an SDL::Rect-based object";
}
if ( _do_rects_intersect( $self, $value ) ) {
Oops, something went wrong.

0 comments on commit c33c981

Please sign in to comment.