Skip to content

Commit

Permalink
Explosion simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpalmer committed Mar 4, 2011
1 parent b61b29e commit 3514cb7
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions week1/lib/Games/SolarConflict/Roles/Explosive.pm
Expand Up @@ -2,7 +2,7 @@ package Games::SolarConflict::Roles::Explosive;
use Mouse::Role;
use SDLx::Sprite::Animated;

requires qw( x y rect draw visible );
requires qw( x y draw visible );

has exploding => (
is => 'rw',
Expand All @@ -20,14 +20,15 @@ around draw => sub {
my ( $orig, $self, $surface ) = @_;

if ( $self->exploding ) {
if ( $self->explosion->current_loop != 1 ) {
my $e = $self->explosion;
if ( $e->current_loop != 1 ) {
$self->exploding(0);
$self->visible(0);
return;
}
$self->explosion->x( $self->x - $self->rect->w / 2 );
$self->explosion->y( $self->y - $self->rect->h / 2 );
return $self->explosion->draw($surface);
$e->x( $self->x - $e->rect->w / 2 );
$e->y( $self->y - $e->rect->h / 2 );
return $e->draw($surface);
}
else {
return $self->$orig($surface);
Expand Down

0 comments on commit 3514cb7

Please sign in to comment.