We have to make a pretty basic ping pong game at school: two paddles, one ball, etc. I had the whole thing done and working, and then my teacher announces that we're not allowed to use the "if on edge, bounce" script. This totally throws me off, because I have no idea how to make it without that. He said something about setting the x to an xVelocity variable and the y to a yVelocity variable, but whenever the ball hits the paddle, it just shoots into the left top corner. I can't figure it out.
Help?!
Offline
Instead, make a sprite that goes around the border. Make it thin so it is hard to notice. Now make this:
<when green flag clicked>
<forever if <touching [border]>
<change direction by ( pick random (20) to (-20) )>
</forever>
Offline
Most pong scripts use a script something like this:
<when green flag clicked>
<point in direction( 90
<forever>
<move( whatever )steps>
<if><< <touching[ edge <or><touching[ paddle >>
<point in direction( (( direction <-> 180 ))
Atleast I think this is how it works . . . Just add velocity from here.
Offline
floatingmagictree wrote:
Instead, make a sprite that goes around the border. Make it thin so it is hard to notice. Now make this:
<when green flag clicked>
<forever if <touching [border]>
<change direction by ( pick random (20) to (-20) )>
</forever>
That would work, but the problem with it is that the bouncing is random; it's not at all accurate. Shadow_7283's does "bounce".
Offline
Oh and for all those previous scripts, you need a sprite called edge, drawn so it's on the top and bottom
Last edited by deatheater (2009-09-19 04:41:38)
Offline
floatingmagictree wrote:
Instead, make a sprite that goes around the border. Make it thin so it is hard to notice. Now make this:
<when green flag clicked>
<forever if <touching [border]>
<change direction by ( pick random (20) to (-20) )>
</forever>
what happens if he notices you without the x velocity and y velocity thing?
Offline