Skip to content

Commit

Permalink
Making actors in a level
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Jun 15, 2012
1 parent a2fab5f commit e36fc1c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
28 changes: 25 additions & 3 deletions lib/Avenger/Actor.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,33 @@ sub actor {

foreach my $actor_key ( keys %args ) {
my $actor_class = "$base::$actor_key";
my $actor; #TODO: Make DSL calling DSL work = $actor_class
my $actor = new( $actor_class, $args{$actor_key} );
#TODO: Make DSL calling DSL work = $actor_class
}

}


sub new {
my $class = shift;
my %args = @_;
my $body_hash = delete $args{body};
my $body = world->create_body( $body_hash );

if(my $v = delete %{$body_hash}{velocity} )
{
$body->velocity( @$v )
}
#HOLY COMMUNION
my $flesh = bless { body => $body }, $class;


$flesh->setup( @_ );

return $flesh;

}

sub import {
my $class = shift;
my %properties = ( ref $_[0] ? %{ $_[0] } : @_ );
Expand All @@ -23,8 +45,8 @@ sub import {
# *{"${caller}::setup"} = sub {$self};
}

sub setup {

sub body {
return $_[0]->{body}
}

sub draw {
Expand Down
8 changes: 4 additions & 4 deletions lib/Zemmings/Actor/Zemming.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package Zemmings::Actor::Zemming;
use Avenger::Actor;

setup {
sub setup {
my $self = shift;
$self->body->velocity = 5;
$self->body->y = 600;
$self->body->x = 100;

# $self->{body} is the body

};

event 'tick' => sub {
Expand Down
2 changes: 1 addition & 1 deletion lib/Zemmings/Level.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ actor 'Zemming' => {
body => {
x => 10,
y => 600,
velocity => { x => 5, y => 0 }
velocity => [ 5, 0 ]
}
};

Expand Down

0 comments on commit e36fc1c

Please sign in to comment.