http://qs321.pair.com?node_id=11119700


in reply to pong paddles are not going equally fast

New paddle position also depends on $step which is the time slice.

When you press UP-arrow this checks only the 1st condition. When you press DOWN-arrow it checks both conditions. Could that be affecting $step? Ideally no but try print $step and see.

if($event-> key_sym == SDLK_UP){ $player1->{v_y} = -2; } elsif($event->key_sym == SDLK_DOWN){ + $player1->{v_y} = 2; }

bw, bliako

Replies are listed 'Best First'.
Re^2: pong paddles are not going equally fast
by choroba (Cardinal) on Jul 23, 2020 at 08:23 UTC
    > Could that be affecting $step?

    Can be easily tested by swapping the conditions.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]