Welcome to the Monastery | |
PerlMonks |
Re: pong paddles are not going equally fastby kcott (Archbishop) |
on Jul 23, 2020 at 11:16 UTC ( [id://11119705]=note: print w/replies, xml ) | Need Help?? |
[Disclaimer: I am not a user of SDL and I do not have it installed. The following is untested guesswork (actually, perl -c says "syntax OK", but untested beyond that).] After looking at your posted code, I had a similar thought to what ++bliako wrote. I can see that you've copied the code from "[PDF] SDL::Manual": a visual inspection shows no problems there. Try replacing this entire call:
with
That will set up all of the possible values for $player1->{v_y} once, at compile time. Assigning those values now only requires a single if condition, instead of the multiple if and elsif conditions you currently have. — Ken
In Section
Seekers of Perl Wisdom
|
|