Skip to content

Commit

Permalink
slightly harder to get stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
zpmorgan committed Mar 10, 2011
1 parent fb060f3 commit 117ce43
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions Entity.pm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ has gravity => (
default => .01,
);

has platform => (
is => 'rw',
);

# walking, freefall, etc
has 'status' => (
is => 'rw',
Expand Down Expand Up @@ -93,7 +97,7 @@ sub do_walking{
$self->{xv} = 0;
}

my $platform = $self->{platform};
my $platform = $self->platform;
#moving left towards wall?
if ($self->{xv} < 0 and $platform->left_edge eq 'wall'){
if ($self->{x} + $self->{xv} < $platform->left_x){
Expand Down Expand Up @@ -125,6 +129,12 @@ sub do_walking{
#moving right towards cliff?
elsif ($self->{xv} > 0 and $platform->right_edge eq 'cliff'){
}
#eliminate boundedness if still moving horizontally
if ($self->xv){
$self->bound_l(0);
$self->bound_r(0);
}

$self->{x} += $self->xv
}

Expand Down Expand Up @@ -223,6 +233,11 @@ sub set_walking{
$self->status('walking');

}
sub set_freefall{
my $self = shift;
$self->platform(undef);
$self->status('freefall');
}

sub set_status{
my ($self, $status) = @_;
Expand Down Expand Up @@ -287,13 +302,14 @@ sub establish_platform{
$r_edge = "cliff" }


$self->{platform} = Platform->new(
my $platform = Platform->new(
y => $py,
left_x => $l,
right_x => $r,
left_edge => $l_edge,
right_edge => $r_edge,
);
$self->platform($platform);
}

sub collision_rect{
Expand Down
2 changes: 1 addition & 1 deletion Level.pm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ sub add_entity{
$entity->{$_} = $params{$_} if $params{$_};
}

#falling? freefall?
#walking? freefall?
$entity->determine_status;

push @{$self->{entities}}, $entity;
Expand Down
2 changes: 1 addition & 1 deletion cyberhack.pl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
if ($pressed{up} and $cryptopod->status eq 'walking'){
$cryptopod->yv(-.3);
$cryptopod->{y} -= .001;
$cryptopod->set_status('freefall');
$cryptopod->set_freefall;
}
$cryptopod->do;
$app->draw_rect( [ 0, 0, $app->w, $app->h ], 0x0 );
Expand Down

0 comments on commit 117ce43

Please sign in to comment.