Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


RAZORUNREAL

Member Since 17 Jan 2004
Offline Last Active Aug 19 2013 11:52 PM

#5050810 Code Review ::Pong Clone::

Posted by RAZORUNREAL on 07 April 2013 - 03:11 AM

I haven't read the whole thing, but based on the ball class my main piece of advice would be this:

Try to reduce the number of conditions. The more similar code paths you have, the more opportunities there are for mistakes, particularly copy&paste errors. For example, rather than your 4 "moving..." booleans use a single velocity Vector2. You can add that to your position every update, avoiding 4 if statements. Then to bounce off the walls you just do velocity.x = -velocity.x




PARTNERS