projects
/
perl-landing-airplanes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
490c8eb
)
cleanup debug
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Wed, 19 May 2010 15:47:13 +0000
(17:47 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Wed, 19 May 2010 16:05:57 +0000
(18:05 +0200)
trace-path.pl
patch
|
blob
|
history
diff --git
a/trace-path.pl
b/trace-path.pl
index
de5d493
..
5f9884a
100755
(executable)
--- a/
trace-path.pl
+++ b/
trace-path.pl
@@
-11,17
+11,19
@@
use SDL::Event;
use Math::CatmullRom;
#use Algorithm::Line::Bresenham;
use Math::CatmullRom;
#use Algorithm::Line::Bresenham;
-use Carp qw
/confess/
;
-use Data::Dump qw
/dump/
;
+use Carp qw
(cluck)
;
+use Data::Dump qw
(dump)
;
-
my
$debug = 0;
+
our
$debug = 0;
my ( $w, $h ) = ( 800, 480 );
my $mouse_trashold = 10;
my $max_path_length = 200;
sub debug {
my ( $w, $h ) = ( 800, 480 );
my $mouse_trashold = 10;
my $max_path_length = 200;
sub debug {
- warn '#', dump @_ if $debug;
+ return unless $debug;
+ my ($package, $filename, $line) = caller;
+ warn '# ', dump( @_ ), " $filename +$line\n";
}
our $app = SDL::App->new(
}
our $app = SDL::App->new(
@@
-76,13
+78,18
@@
sub handle_events {
my $key = $event->key_name;
debug 'key down', $key;
exit if $key =~ m/^[xq]$/;
my $key = $event->key_name;
debug 'key down', $key;
exit if $key =~ m/^[xq]$/;
- if ( $key eq 's' ) {
+ if ( $key eq 's' ) {
# XXX draw curve
curve;
curve;
- } elsif ( $key eq '
d' ) {
+ } elsif ( $key eq '
backspace' ) { # XXX clean screen
@path = ();
my $rect = SDL::Rect->new( -x => 0, -y => 0, -w => $w, -h => $h );
$app->fill( $rect, $black );
$app->update( $rect );
@path = ();
my $rect = SDL::Rect->new( -x => 0, -y => 0, -w => $w, -h => $h );
$app->fill( $rect, $black );
$app->update( $rect );
+ } elsif ( $key eq 'd' ) { # XXX toggle debug
+ $debug = ! $debug;
+ warn "debug $debug\n";
+ } else {
+ warn "unknown key $key";
}
} elsif ( $type == SDL_KEYUP() ) {
debug 'key up', $event->key_name;
}
} elsif ( $type == SDL_KEYUP() ) {
debug 'key up', $event->key_name;
@@
-105,7
+112,7
@@
sub handle_events {
}
}
} else {
}
}
} else {
-
debug 'unknown', $type
;
+
warn "unknown type $type\n"
;
}
}
};
}
}
};