use Data::Dump qw/dump/;
my ( $w, $h ) = ( 800, 480 );
+my $mouse_trashold = 10;
our $app = SDL::App->new(
-width => $w,
our $white = SDL::Color->new( 0xff, 0xff, 0xff );
+my ( $last_x, $last_y ) = ( 0,0 );
+
sub handle_events {
while ( $event->wait ) {
warn "key up ", $event->key_name,$/;
} elsif ( $type == SDL_MOUSEMOTION() ) {
# warn "mouse ", $event->motion_xrel, ' ', $event->motion_yrel;
- warn "mouse $mouse_down @ ", $event->motion_x, ' ', $event->motion_y;
- if ( $mouse_down ) {
+ my ( $x, $y ) = ( $event->motion_x, $event->motion_y );
+ warn "mouse $mouse_down @ $x*$y\n";
+ my $dx = abs( $last_x - $x );
+ my $dy = abs( $last_y - $y );
+ if ( $mouse_down && ( $dx > $mouse_trashold || $dy > $mouse_trashold ) ) {
my $rect = SDL::Rect->new( -x => $event->motion_x, -y => $event->motion_y, -w => 3, -h => 3 );
$app->fill( $rect, $white );
$app->update( $rect );
+ $last_x = $x;
+ $last_y = $y;
}
} else {
warn "unknown $type\n";