Permalink
Browse files

Omit rectangles where optional

  • Loading branch information...
1 parent a6c8bd0 commit 8e2713b4fed9b10bd1e868ed65dbf245b871f2dd @jtpalmer committed Jan 10, 2011
Showing with 6 additions and 13 deletions.
  1. +6 −13 lib/Games/Sokoban/SDL.pm
View
19 lib/Games/Sokoban/SDL.pm
@@ -51,26 +51,20 @@ sub init_level {
@boxes = ();
- $background->draw_rect( [ 0, 0, 640, 480 ], 0x000000ff );
+ $background->draw_rect( undef, 0x000000ff );
my ( $x, $y ) = ( 0, 0 );
foreach my $row ( $level->as_lines ) {
$x = 0;
foreach my $element ( split //, $row ) {
given ($element) {
$grid->[$x][$y] = $_;
when ('#') {
- $wall->blit(
- $background,
- [ 0, 0, $size, $size ],
- [ $x * $size, $y * $size, $size, $size ]
- );
+ $wall->blit( $background, undef,
+ [ $x * $size, $y * $size, $size, $size ] );
}
when ('.') {
- $goal->blit(
- $background,
- [ 0, 0, $size, $size ],
- [ $x * $size, $y * $size, $size, $size ]
- );
+ $goal->blit( $background, undef,
+ [ $x * $size, $y * $size, $size, $size ] );
}
when ('$') {
push @boxes,
@@ -94,7 +88,6 @@ sub init_level {
}
$y++;
}
-
}
sub move_player {
@@ -163,7 +156,7 @@ sub handle_event {
my ( $e, $app ) = @_;
if ( $e->type == SDL_KEYDOWN ) {
- init_level() if SDL::Events::get_key_name($e->key_sym) eq 'r';
+ init_level() if SDL::Events::get_key_name( $e->key_sym ) eq 'r';
if ( !$player_moving && !$player_vx && !$player_vy ) {
move_player('west') if $e->key_sym == SDLK_LEFT;

0 comments on commit 8e2713b

Please sign in to comment.