Skip to content

Commit

Permalink
Clean up image and sprite sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
f0rodo committed Aug 19, 2010
1 parent 504a3ed commit 684629b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Binary file modified data/m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions scroller.pl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
my @update_rects = ();

my $sprite = SDLx::Sprite::Animated->new(
image => 'data/m.bmp',
image => 'data/m.png',
rect => SDL::Rect->new( 0, 0, 16, 28 ),
ticks_per_frame => 2,
);
Expand Down Expand Up @@ -96,6 +96,9 @@
}
if ( $pressed->{up} && !$lockjump ) {

$sprite->sequence('jumpr') if ( $sprite->sequence() =~ 'r');
$sprite->sequence('jumpl') if ( $sprite->sequence() =~ 'l');

$state->v_y($vel_y);
$lockjump = 1;

Expand Down Expand Up @@ -127,6 +130,8 @@
my $block = $collision->[1];
$state->y( $block->[1] + $block->[3] + 3 );
$state->v_y(0);


}
else {

Expand All @@ -143,14 +148,16 @@
$state->v_y(0); # Causes test again in next frame
$ay = 0;
$lockjump = 0 if ( !$pressed->{up} );
$sprite->sequence( 'stopr' ) if $sprite->sequence =~ 'r';
$sprite->sequence( 'stopl' ) if $sprite->sequence =~ 'l';

}
else #falling in air
{
else
{ #falling in air

$ay = $gravity;

# $lockjump = 1;
# $lockjump = 1;

}
}
Expand Down Expand Up @@ -192,7 +199,7 @@

my $c_rect = SDL::Rect->new( $state->x, $state->y, 16, 28 );

$app->draw_rect( $c_rect, 0xFF00CCFF );
# $app->draw_rect( $c_rect, 0xFF00CCFF );

# $app->draw_rect( [50,50, 16, 28], 0xFF00CCFF );
$sprite->x( $state->x );
Expand Down

0 comments on commit 684629b

Please sign in to comment.