-1

Ok, soI have this code that makes it so that the ball just rests on the paddle instead of bouncing off. So, my solution would be to do something like break; but for if statements. Problem being such a thing does not exist. So, what else can I do? Also, is any more context is needed?

1 Answer 1

0

why do you need to break? make your else statement an else if or separate if statement so each case is evaluated individually.

instead of

if(ball hits paddle)
   \\bounce back
else
   \\do something else

make it

if(ball hits paddle)
  \\bounce back
else if(ball hits brick)
  \\do something

or even

 if(ball hits paddle)
      \\bounce back

 if(ball hits brick)
      \\do something

If statements can exist without elses.

1
  • well, I'm not so sure how well that would work because my bricks were cast as a 2-d array, and I have no way of knowing which brick it hit... unless I try all the bricks. Also, I thought "break" because the problem in my eyes seems to be that it continues to detect the collision.
    – Phoxxent
    Nov 18, 2014 at 1:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .