projects
/
perl-landing-airplanes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added Airplane object
[perl-landing-airplanes.git]
/
trace-path.pl
diff --git
a/trace-path.pl
b/trace-path.pl
index
afb304d
..
0fe9353
100755
(executable)
--- a/
trace-path.pl
+++ b/
trace-path.pl
@@
-14,6
+14,9
@@
use Algorithm::Line::Bresenham qw(line);
use Carp qw(cluck);
use Data::Dump qw(dump);
use Carp qw(cluck);
use Data::Dump qw(dump);
+use Airplane;
+our @airplanes;
+
our $debug = 0;
my ( $w, $h ) = ( 800, 480 );
our $debug = 0;
my ( $w, $h ) = ( 800, 480 );
@@
-146,6
+149,8
@@
sub curve {
sub { $app->pixel( @_, $path_color ) }
);
}
sub { $app->pixel( @_, $path_color ) }
);
}
+ push @airplanes, Airplane->new( $app );
+ $airplanes[-1]->set_path( @path );
$app->sync;
reset_path;
}
$app->sync;
reset_path;
}
@@
-166,7
+171,7
@@
sub clear_screen {
sub handle_events {
sub handle_events {
- while ( $event->
wait
) {
+ while ( $event->
poll
) {
my $type = $event->type();
if ( $type == SDL_MOUSEBUTTONDOWN() ) {
my $type = $event->type();
if ( $type == SDL_MOUSEBUTTONDOWN() ) {
@@
-210,7
+215,7
@@
sub handle_events {
$app->fill( $rect, $mouse_color );
$app->update( $rect );
$last_x = $x;
$app->fill( $rect, $mouse_color );
$app->update( $rect );
$last_x = $x;
-
$last_y = $y;
+ $last_y = $y;
} else {
$mouse_down = 0;
curve;
} else {
$mouse_down = 0;
curve;
@@
-224,8
+229,9
@@
sub handle_events {
while(1) {
handle_events;
while(1) {
handle_events;
+ $_->draw foreach @airplanes;
+ $app->delay(50);
$app->sync;
$app->sync;
- $app->delay(1);
}
1;
}
1;