This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-01-21 23:19:57

kittenlols
Scratcher
Registered: 2010-01-21
Posts: 31

Bounce against object

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

 

#2 2010-01-22 00:31:12

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Bounce against object

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)


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#3 2010-01-22 05:41:11

kittenlols
Scratcher
Registered: 2010-01-21
Posts: 31

Re: Bounce against object

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

 

#4 2010-01-22 05:45:06

juststickman
Scratcher
Registered: 2009-05-31
Posts: 1000+

Re: Bounce against object

I think this engine has perfect bounce physics (or close to): http://scratch.mit.edu/projects/justtestingstickman/853661
(with gravity)


http://is.gd/iBQi2 Add grob to your sig and help with world dominiation!http://is.gd/iBQ9Q                                                             Hey guys, we're seriously naming our team bob?

Offline

 

#5 2010-01-22 19:25:15

kittenlols
Scratcher
Registered: 2010-01-21
Posts: 31

Re: Bounce against object

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

 

#6 2010-01-22 20:05:14

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: Bounce against object

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?


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

#7 2010-01-23 19:50:04

kittenlols
Scratcher
Registered: 2010-01-21
Posts: 31

Re: Bounce against object

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

 

#8 2010-01-25 05:25:51

kittenlols
Scratcher
Registered: 2010-01-21
Posts: 31

Re: Bounce against object

How do you make a ball bounce off the wall?

Offline

 

Board footer