I have an issue here which is that I am making a game which you use a paddle to beat the ball towards the bricks and break them (very common). It's just that I don't know how to get the ball to move according to correct physics and bounce back. Can someone help?
Offline
Well, this is hard. Basically, when the ball comes down, you need to negate the direction. I would use point in direction: (direction)*(-1). Also, use [if on edge bounce] for walls. Good luck
P.S. AI means Artificial Intelligence, meaning the computer makes decisions based on the situation. Here, the algorithm is fixed, so it's not AI.
Last edited by Hardmath123 (2011-03-29 10:17:59)
Offline
Hardmath for the most part is correct, though instead of direction*-1, it would work better if you use ((direction*-1)+180). This makes more realistic turnings.
Edit: Actually my method is also not completely correct. Use direction*-1 when the collision is from the sides and (direction*-1)+180 when it's from the top or bottom.
You can do this by making sensor sprites (or a sensor costume).
Make the ball have a separate costume with a certain color on it's left and right and a certain color on it's top and bottom. Make everything else black or some other color.
Like this:
(Note: Make the size of this costume the same as the size of your ball)
Now put a script like this in your movement script for the ball:
(Note: This must be put into your movement script, or at least into a forever loop).
Last edited by Kileymeister (2011-03-29 15:40:06)
Offline
Kileymeister: I'm not sure there's a motion block with only the word 'direction'. Where do you find that?
Offline
IdozenCair wrote:
Kileymeister: I'm not sure there's a motion block with only the word 'direction'. Where do you find that?
You find that in the motion, under the X position and Y position
Offline
ssss wrote:
IdozenCair wrote:
Kileymeister: I'm not sure there's a motion block with only the word 'direction'. Where do you find that?
You find that in the motion, under the X position and Y position
![]()
...at the very bottom
Offline