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

#1 2007-12-24 07:37:32

messd002
Scratcher
Registered: 2007-12-07
Posts: 100+

Need Bouncing script.

I have been trying for ages and I can't seem to get a perfect bounce. I am working on a game of snooker/pool (don't know which yet, still making one ball perfect.) and have already developed a power bar which will knock the ball acording to the power. However, I Have made (on the background) a table with a blue edge and green inside. I need it so that if I knock the ball at the edge at, lets say, 45 degrees I need it bounce off as it would in real life. All help appreciated.


Burn baby Burn!

Offline

 

#2 2007-12-24 15:46:12

fraster
Scratcher
Registered: 2007-12-24
Posts: 2

Re: Need Bouncing script.

hey there, im working on a game of pool aswell. i started yesterday, and i am quite far in. I have all the ball on the table, they are potable, they bounce and so forth. im on a break for now. it was heavy work. anyway, if i understand you need to make the balls bounce of the edge of the table?

this is the method i used:
first, make each edge of the table a different sprite and it will make this alot easyier!

<when green flag clicked>
<forever>
<if> < touching[sprite14] >
<point in direction( (( 180 <-> <direction> )) )
<wait( 0.3 )secsc>

in this case, sprite 14 was the top cusion on my table. you use the same script for the bottom cusion.  however, the right and left cusion both need a different script, which is

<when green flag clicked>
<forever>
<if> <touching[sprite12]>
<point in direction( (( 360 <-> <direction> )) )
<wait( 0.3 ) secsc>

i hope that came out clear...

if i didnt make it clear enough or i didnt even answer ur question message me and il try to make myself clearer  tongue


P.S. Do Pool, its alot easyier than snooker!

Offline

 

#3 2007-12-24 18:08:31

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Need Bouncing script.

I removed all the "bump" messages, as they do nothing to speed things up—they just clutter the forum.

You can find a very useful ball script in the School Pinball game that my son and I wrote.
It is currently intended for one ball and many stationary objects to bounce off of, but could be adapted for multiple balls.

http://scratch.mit.edu/projects/kevin_and_abe/54377

Offline

 

#4 2007-12-25 13:23:59

messd002
Scratcher
Registered: 2007-12-07
Posts: 100+

Re: Need Bouncing script.

Thanks for the script and thanks for removing bumps. In some forums they move the thread up.


Edit: Ummm, it doesn't work for top cussion, havn't tried left/right.

Last edited by messd002 (2007-12-25 13:30:56)


Burn baby Burn!

Offline

 

#5 2007-12-26 14:55:39

Dthen
Scratcher
Registered: 2007-05-16
Posts: 26

Re: Need Bouncing script.

I'm working on a clone of the game Inkball, and am trying to work out a script for this as well. The main problem I have is it needs to be colour based for mine. Except possibly for the edges. And my main problem is that The ball tends to get... stuck at the edges

Offline

 

Board footer