Hello everyone,
I've found this pong patch on the forums here and am trying to add another canvas element in the center that will bounce the ball if hit. Does anyone have any advice?
Thanks
Adding to a pong patch
Hello everyone,
I've found this pong patch on the forums here and am trying to add another canvas element in the center that will bounce the ball if hit. Does anyone have any advice?
Thanks
i made that patch, and been a while since i looked at it. Inserting one more canvas in the middle is not a small task, but here's some quick advice if you really want to do it:
at the moment, the x-value for 'ballpos' (ball position) is detected on the 2 walls by [sel 0 480], at which point a new angle is sent to hit the ball back.
if you have a canvas in the middle, you will need to detect both the x and y values for ballpos, and send a new angle when ballpos is within the middle area. So, you need to use quite a larger routine than just [sel 0 480].
The basic idea would be something like:
if ballpos x is greater than 230 and less than 250,
AND
ballpos y is greater than 180 and less than 200,
THEN
change the angle and direction of the ball accordingly.
Thanks for the reply.
Didn't you do the Arkanoid one as well? Both of them are neat patches. Thanks for putting them on the forum. I'm just tryin' to learn a few tricks.
yeah. actually, you'd be better off looking at the arkanoid one. Probably a bit more logically patched.
Oops! Looks like something went wrong!