Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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