Hi, is there any way for a object to bounce against another object? I'm doing a ice hockey game, and the way it moves need to depend on where the paddle is hit, so a simple direction won't work..
Offline
Can you post what you have coded so far? I did something like this for a Pong game. In mine, the ball bounces normally off walls but the bounce angle off the paddle is adjusted according to where the ball strikes the paddle. The solution for this was to figure the bounce angle normally, then adjust that by comparing ball and paddle y values. Here is my game...
http://scratch.mit.edu/projects/Locomule/737050
I always ask people to post their work in progress because although there are many solutions to the same problem, there is usually only one solution which works best for your specific purposes. I will check back here.
Last edited by Locomule (2010-01-22 00:35:02)
Offline
Actually I changed my mind, to do a volleyball game. I'm thinking if I don't start physics, maybe there will be more ways to tackle the problem?
http://scratch.mit.edu/projects/kittenlols/854778
Offline
I think this engine has perfect bounce physics (or close to): http://scratch.mit.edu/projects/justtestingstickman/853661
(with gravity)
Offline
Updated:
http://scratch.mit.edu/projects/kittenlols/855812
I'm thinking that there are 2 parts per slime, if the ball touches the left part then it goes left, if it touches the right part it goes right. Not sure how to do that through
Offline
Thanks juststickman! I take it the waffle square is turned on end to avoid the whole "what if it hits perfectly in the corner" issue perhaps? Cool app. I agree, the side view perspective, physics and bounce engine, would be a great fit for Kittenlols project.
Kittenlols, all I can say is wow, that looks awesome! As an artist, I am usually guilty of skimping on graphics so I can concentrate on programing. What do you think about modifying his engine?
Offline
I've managed to use a simple ide:
if x pos < ballx
broadcast ball_goleft
else
broadcast ball_goright
Works pretty well, not very smooth, but hey, at least it works without getting me puzzled over trying to modify a complex engine.. However, I need for the ball to bounce off the wall.
http://scratch.mit.edu/projects/kittenlols/857658
And I think this is the only volley with pause feature! Space = (un)PAUSE
Sorry for displaying all variables - I used that to squash bugs.
Offline
How do you make a ball bounce off the wall?
Offline