Computer Science Canada

pong - not collision detection but something like it

Author:  Blade [ Tue Jun 03, 2003 12:05 pm ]
Post subject:  pong - not collision detection but something like it

ok. i had no clue what to call this but heres the problem:
i have my little bouncie ball runnin around on the screen. and when it hits my paddle it bounces off right? ok. so when the ball is moving it has to bounce off of the top part of my paddle. so i need to set vx to -vx so it will bounce off or else it will run right throught the paddle bouncing through. but the thing is when i do this the ball just bounces around in a circle so it would hit the top, then bounce around in a circle, hit the bottom, bounce back around hit the same spot as before at the top. and keep doing it like that.... is there any other way to make it more random without the ball speeding up that much?

Author:  Tony [ Tue Jun 03, 2003 12:38 pm ]
Post subject: 

I think I mentioned it before... have rounded edges with circle reflection so that you can actually have some control of where the ball would go

Author:  Blade [ Tue Jun 03, 2003 2:26 pm ]
Post subject: 

i dont really understand... i can still have control of where the ball goes... its just i want to make it more random..

Author:  Tony [ Tue Jun 03, 2003 2:36 pm ]
Post subject: 

well when it hits your paddle, doesn't it just bounce back up?

vY *= -1

to make it more random, you need to change the vX as well

Author:  Blade [ Tue Jun 03, 2003 5:53 pm ]
Post subject: 

yeah but thats isnt really the problem... it just bounces around in a circle. it hits the same spots. i need it to be more random

Author:  Tony [ Tue Jun 03, 2003 6:48 pm ]
Post subject: 

thats what I keep on telling you... if you shift the velocity along the X axis as well, it you gradually move that circle...

having rounded edges would allow you to implement same collision physics as in pool.

Author:  Blade [ Tue Jun 03, 2003 8:59 pm ]
Post subject: 

ah ic... so i need a round paddle? because i mean, it does it when it hits the sides too


: