0

I am having trouble with hitting all my bricks. I'm done with all 10 steps in the pset but when I get to hitting the last 3 - 5 or so bricks, my ball doesn't have enough "randomness" to hit them. My x velocity is set to drand48 * 4 - 2 and my y velocity is set to drand 48 with an if statement setting my y velocity to -4.0 if it's greater than .5 and to 2.0 if it's less than .5. I've tried multiple other drand48 setting and the one I describe here is the only one that works to the point hitting almost all the bricks.

Any hints? Much appreciated! Cant wait to finish this and move on to pset 5.

0

I'd say to check out your bounce logic, both off of the bricks and off of the paddle. you can modify variables on bounce also, to change speed or direction for example

| improve this answer | |
  • Thanks. I'll take a look, but my bounce logic is fine, its just that the ball is not moving in the direction to hit the last remaining bricks. It just hits the same spot on the window where no bricks are left. Maybe add some logic to change the speed if it hits the widows top edge? – Msholly Jun 16 '14 at 18:32
  • There a lot of adjustments that you could make, such as decrementing by .01 on a brick, incrementing by twice that off a paddle, etc. If fixed values aren't working, change them up. – Sean DiSanti Jun 17 '14 at 0:11
  • Thanks, I finally got it to hit all the bricks; although it did take several bounces on the windows edges (which modified the velocity) to actually hit the last 3 bricks. – Msholly Jun 17 '14 at 17:34
  • Good deal. I was debating adding my bounce logic based on the quadrant making contact in the detectCollision() function but decided it was a little overkill. – Sean DiSanti Jun 18 '14 at 6:39

You must log in to answer this question.

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