Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: pong paddles are not going equally fast

by bliako (Prior)
on Jul 23, 2020 at 08:10 UTC ( #11119700=note: print w/replies, xml ) Need Help??


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 (Archbishop) 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]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11119700]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-12-06 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (65 votes). Check out past polls.

    Notices?