Skip to content

Commit

Permalink
make zumbis work with master branch of sdl again
Browse files Browse the repository at this point in the history
  • Loading branch information
ruoso committed Jul 29, 2010
1 parent ca8ca83 commit b38bdd6
Showing 1 changed file with 28 additions and 26 deletions.
54 changes: 28 additions & 26 deletions lib/Games/Zumbis/Zumbi.pm
Expand Up @@ -11,12 +11,6 @@ use constant SPRITE_WIDTH => 32;
use constant SPRITE_HEIGHT => 45;
use constant SPRITE_TPS => 2;

my $imagem_zumbi = SDL::Image::load( Games::Zumbis->sharedir->file('dados/zumbi.png') );
my $rect_zumbi = SDL::Rect->new(SPRITE_NUM_COLS,
SPRITE_NUM_ROWS,
SPRITE_WIDTH,
SPRITE_HEIGHT);

has x => (is => 'rw', required => 1);
has y => (is => 'rw', required => 1);
has sprite => (is => 'ro', handles => ['sequence']);
Expand All @@ -28,33 +22,41 @@ has dt => (is => 'rw', default => 0 );

sub set_new_dt { (500 + rand 10) }

my $imagem_zumbi = SDL::Image::load( Games::Zumbis->sharedir->file('dados/zumbi.png') );
my $rect_zumbi = SDL::Rect->new(SPRITE_NUM_COLS,
SPRITE_NUM_ROWS,
SPRITE_WIDTH,
SPRITE_HEIGHT);

sub BUILDARGS {
my ($self, %args) = @_;

my $z = SDLx::Sprite::Animated->new
( surface => $imagem_zumbi,
rect => $rect_zumbi,
ticks_per_frame => SPRITE_TPS,
sequence => 'parado_baixo',
sequences =>
{ parado_esquerda => [ [1, 3] ],
parado_direita => [ [1, 1] ],
parado_cima => [ [1, 0] ],
parado_baixo => [ [1, 2] ],
esquerda => [ [0,3], [1,3], [2,3] ],
direita => [ [0,1], [1,1], [2,1] ],
cima => [ [0,0], [1,0], [2,0] ],
baixo => [ [0,2], [1,2], [2,2] ],
morrendo_cima => [ [0,4], [1,4], [2,4], [0,8], [1,8], [2,8] ],
morrendo_direita => [ [0,5], [1,5], [2,5], [0,8], [1,8], [2,8] ],
morrendo_baixo => [ [0,6], [1,6], [2,6], [0,8], [1,8], [2,8] ],
morrendo_esquerda => [ [0,7], [1,7], [2,7], [0,8], [1,8], [2,8] ],
morrendo_parado_cima => [ [0,4], [1,4], [2,4], [0,8], [1,8], [2,8] ],
morrendo_parado_direita => [ [0,5], [1,5], [2,5], [0,8], [1,8], [2,8] ],
morrendo_parado_baixo => [ [0,6], [1,6], [2,6], [0,8], [1,8], [2,8] ],
morrendo_parado_esquerda => [ [0,7], [1,7], [2,7], [0,8], [1,8], [2,8] ],
});

);

$z->set_sequences
( parado_esquerda => [ [1, 3] ],
parado_direita => [ [1, 1] ],
parado_cima => [ [1, 0] ],
parado_baixo => [ [1, 2] ],
esquerda => [ [0,3], [1,3], [2,3] ],
direita => [ [0,1], [1,1], [2,1] ],
cima => [ [0,0], [1,0], [2,0] ],
baixo => [ [0,2], [1,2], [2,2] ],
morrendo_cima => [ [0,4], [1,4], [2,4], [0,8], [1,8], [2,8] ],
morrendo_direita => [ [0,5], [1,5], [2,5], [0,8], [1,8], [2,8] ],
morrendo_baixo => [ [0,6], [1,6], [2,6], [0,8], [1,8], [2,8] ],
morrendo_esquerda => [ [0,7], [1,7], [2,7], [0,8], [1,8], [2,8] ],
morrendo_parado_cima => [ [0,4], [1,4], [2,4], [0,8], [1,8], [2,8] ],
morrendo_parado_direita => [ [0,5], [1,5], [2,5], [0,8], [1,8], [2,8] ],
morrendo_parado_baixo => [ [0,6], [1,6], [2,6], [0,8], [1,8], [2,8] ],
morrendo_parado_esquerda => [ [0,7], [1,7], [2,7], [0,8], [1,8], [2,8] ],
);

$z->sequence('parado_baixo');
$z->start();

return { %args, sprite => $z };
Expand Down

0 comments on commit b38bdd6

Please sign in to comment.