I decided to make a realistic version of "pong" which included a computer opponent because all the versions I could find either; relied on a random angle to bounce the ball away from the racket or where pvp on one keyboard.
I think that my version is simple and effective.
Here it is:
pong
I think one of the complicated things about this was making the ball bounce off of the racket at the correct angle.
Most of the pong remakes I have seen on scratch rely on a random number generator for the ball to bounce at an angle.
My version makes the ball bounce up when it hits the top of the racket and down when it hits the bottom.
I did this by making a script to find the difference between the ball's y axis and the racket's y axis and adding or subtracting the difference to 90degrees.
I cant be bothered showing it in blocks. So ill write it out.
when green flag clicked
forever if <touching red paddle>
point in direction(90+([y position of blue paddle]-[y position of ball])
And for the other angle
when green flag clicked
forever if <touching blue paddle>
point in direction(-90-([y position of blue paddle]-[y position of ball])
Offline