Skip to content
Browse files

Multiple plasma

  • Loading branch information...
1 parent 8c70c7b commit b2e06ea6d044f87ce2ba52a8879aa0c23e319333 @jtpalmer committed Mar 26, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 week4/lib/Games/ElectricLines.pm
View
17 week4/lib/Games/ElectricLines.pm
@@ -62,6 +62,18 @@ has _plasma => (
default => sub { [] },
);
+has _plasma_frequency => (
+ is => 'rw',
+ isa => 'Num',
+ default => 10,
+);
+
+has _plasma_time => (
+ is => 'rw',
+ isa => 'Num',
+ default => 0,
+);
+
sub _build_app {
return SDLx::App->new(
title => 'Electric Lines',
@@ -162,6 +174,11 @@ sub _store_active_line {
sub handle_move {
my ( $self, $step, $app, $t ) = @_;
+ if ( $t > $self->_plasma_time + $self->_plasma_frequency ) {
+ $self->_plasma_time($t);
+ $self->_add_plasma();
+ }
+
foreach my $plasma ( @{ $self->_plasma } ) {
$self->_move_plasma( $plasma, $step );
}

0 comments on commit b2e06ea

Please sign in to comment.
Something went wrong with that request. Please try again.