If you want more balls then download the source and use the copy tool. You can have only 3 large collision objects, but you can have as many smaller ones as your computer can run.
Martin, that's really cool. I'm happy to see the code get reused. I do really like the pinball machine idea. I will have to add some flat surfaces to get that to work properly, but it shouldn't be too difficult.
Canthiar: Good idea! I hope you like my modifications (Soundcolors) at: (link to project)
It lacks the purity of your original but it's somehow even more fun :-). Mohlar's above idea to make a Pinball-Mashine out of it sounds great!
Thanks for the suggestion Martin, I've uploaded a new version that can be downloaded. I hadn't expected people to download and run it and didn't notice the issue with this program until after I tried to download it. I did make a post in the forums about this issue.
Addendum: After saving an loading the problem is back again: You can't save the current version "Bouncing Balls" with SCRATCH 1.2! You have to carry out your above correction every time after loading it!
A work-around is writing: 25/1000000 instead of 0.000025 (but that costs some calculatingtime).
You have 0.000025 also in the last line of your "cos"-function in your math-library-sprite.
Canthiar, thank you very much! It worked immediately. Who could think of this? Did you already report the bug to the SCRATCH-Makers? I wished the Squeak-Smalltalk-Source-Code of SCRATCH would have been published already (it's said to be published end of 2007), than we had a chance to fix those kind of bugs ourself. Furthermore you could implement trigonometrically functions and other stuff (your replacement for that in "Bouncing Balls" is great!). It would be wonderfull to have a SCRATCH that you could parameterise from "beginner" to "pro": So students could start with a few concepts and got more and more up to a fully Smalltalk-like environment. What do you think?
Martin, I do know what the problem is. There is a bug in scratch when it reads files that have a small number in them. You're going to have to delete every ball except one. Then 3/4 into the ball code and you should see [set result to ((result) + ((angle power) * (2.5e-5)))]. Change the 2.5e-5 to 0.000025. Then click on the copy button, hold down the shift key and click on the ball sprite several times.
Hi Canthiar: Can you help me? After downloading and running it in SCRACTCH 1.2, the balls vanish directly after hitting the collision-Objects. Do you know that phenomenon?
Very smooth and great bounce physics. All sorts of possibilities here for developing games or other simulations. I'd guess this could also offer a great starting point for a pinball machine game. VERY nice.
You can move the object emitter around with the mouse and change the direction by clicking on the pointed end.
This is what I consider a production version since I've inlined a few things. I have a more academic version that is a little easier to read. The whole thing is also dumbed down a little to make the math a little easier.
How it works:
When a ball encounters a collision object it uses the [ point towards[ Collision ] ] command block and then uses sin and cos to calculate a colliion normal. That normal is used to calculate a resulting velocity perpendicular to the surface and velocity tangent to the surface. Friction and restitution are applied to make the ball bounce.
Comments
You need to be logged in to post comments
Add a Comment
cool!
(view all replies)Comment Reply
woah!!!!!!
(view all replies)Comment Reply
(:-O) (That is the most complicated piece of scratch code i have ever seen!) AMAZING!!!!!!!!
(view all replies)Comment Reply
i dont get it???????????/
(view all replies)Comment Reply
ohoh so many variables
(view all replies)Comment Reply
this is good lol i wish i made it!
(view all replies)Comment Reply
all your projects are scientific or mathematic... its cool!!
(view all replies)Comment Reply
oh
(view all replies)Comment Reply
Restitution is a fancy word for bounciness.
(view all replies)Comment Reply
Whats restitution in this case?
(view all replies)Comment Reply
Sick!
(view all replies)Comment Reply
Nice piece of programing, please check out some of my pojects!
(view all replies)Comment Reply
Argh! My stupid computer wont let play anything! sgdbvxdhcxdhvchnasbdchzsbjcmvjmsdbjkcmsdbc!
(view all replies)Comment Reply
i hav to now admit u r the best programmer on scrathc after see ing this
(view all replies)Comment Reply
yet another great project! check out his random maze program its a-maze-ing
(view all replies)Comment Reply
Cool, glad to hear it all worked out. I may roll that change back into this program.
(view all replies)Comment Reply
Canthiar: Thank you for your help! Now it works: http://scratch.media.mit.edu/projects/MartinWollenweber/8708
(view all replies)Comment Reply
I saw that earlier, but figured it was solved. I will take another look.
(view all replies)Comment Reply
Hi Canthiar! Can you help to solve folowing problem with a mod-version of Bouncing Balls? (link to forums)
(view all replies)Comment Reply
Eyvind: That was a typo it's SCRATCH 1.1
(view all replies)Comment Reply
you're brilliant.... that's all I can say....
(view all replies)Comment Reply
Excuse me MartinWollenweber, where do you download scratch 1.2?
(view all replies)Comment Reply
If you want more balls then download the source and use the copy tool. You can have only 3 large collision objects, but you can have as many smaller ones as your computer can run.
(view all replies)Comment Reply
how do you make it fire more balls
(view all replies)Comment Reply
Or a good one.
(view all replies)Comment Reply
Thats not a baad comment
(view all replies)Comment Reply
This reminds me of cows jumping over the moon, believe it or not.
(view all replies)Comment Reply
It didn't start off being very large, but getting it to run fast required me to inline the sin and cos calculations which bloated it a little bit.
(view all replies)Comment Reply
this must have had a monster scrip
(view all replies)Comment Reply
Hey, someone make a pong game outta this or something.
(view all replies)Comment Reply
wow!
(view all replies)Comment Reply
Check out what MartinWollenweber has done, I think it's a pretty good version 2.
(view all replies)Comment Reply
The Best! Why not have version 2?
(view all replies)Comment Reply
d00d 3p1x
(view all replies)Comment Reply
that is aw3som3 but th3 dir3ctions ar3 too complicat3d for m3...h3h3...m3 l3ss than 3 it...h3h3 g3t it...<3 it
(view all replies)Comment Reply
Martin, that's really cool. I'm happy to see the code get reused. I do really like the pinball machine idea. I will have to add some flat surfaces to get that to work properly, but it shouldn't be too difficult.
(view all replies)Comment Reply
Canthiar: Good idea! I hope you like my modifications (Soundcolors) at: (link to project) It lacks the purity of your original but it's somehow even more fun :-). Mohlar's above idea to make a Pinball-Mashine out of it sounds great!
(view all replies)Comment Reply
Thanks for the suggestion Martin, I've uploaded a new version that can be downloaded. I hadn't expected people to download and run it and didn't notice the issue with this program until after I tried to download it. I did make a post in the forums about this issue.
(view all replies)Comment Reply
I think I will make that change and upload it so that other people can download this and make change changes as they see fit.
(view all replies)Comment Reply
cool!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(view all replies)Comment Reply
Addendum: After saving an loading the problem is back again: You can't save the current version "Bouncing Balls" with SCRATCH 1.2! You have to carry out your above correction every time after loading it! A work-around is writing: 25/1000000 instead of 0.000025 (but that costs some calculatingtime). You have 0.000025 also in the last line of your "cos"-function in your math-library-sprite.
(view all replies)Comment Reply
Canthiar, thank you very much! It worked immediately. Who could think of this? Did you already report the bug to the SCRATCH-Makers? I wished the Squeak-Smalltalk-Source-Code of SCRATCH would have been published already (it's said to be published end of 2007), than we had a chance to fix those kind of bugs ourself. Furthermore you could implement trigonometrically functions and other stuff (your replacement for that in "Bouncing Balls" is great!). It would be wonderfull to have a SCRATCH that you could parameterise from "beginner" to "pro": So students could start with a few concepts and got more and more up to a fully Smalltalk-like environment. What do you think?
(view all replies)Comment Reply
Martin, I do know what the problem is. There is a bug in scratch when it reads files that have a small number in them. You're going to have to delete every ball except one. Then 3/4 into the ball code and you should see [set result to ((result) + ((angle power) * (2.5e-5)))]. Change the 2.5e-5 to 0.000025. Then click on the copy button, hold down the shift key and click on the ball sprite several times.
(view all replies)Comment Reply
Hi Canthiar: Can you help me? After downloading and running it in SCRACTCH 1.2, the balls vanish directly after hitting the collision-Objects. Do you know that phenomenon?
(view all replies)Comment Reply
Nice
(view all replies)Comment Reply
Great!
(view all replies)Comment Reply
awsome
(view all replies)Comment Reply
kool
(view all replies)Comment Reply
this is cool.
(view all replies)Comment Reply
kool
(view all replies)Comment Reply
all american rejects rock!
(view all replies)Comment Reply
This program stems from this discussion in the forums: (link to forums)
(view all replies)Comment Reply
i love my chemical romance,yeah, I'm random. So what?
(view all replies)Comment Reply
Be my friend!
(view all replies)Comment Reply
KOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
(view all replies)Comment Reply
Very smooth and great bounce physics. All sorts of possibilities here for developing games or other simulations. I'd guess this could also offer a great starting point for a pinball machine game. VERY nice.
(view all replies)Comment Reply
Fantastic, I had a marble game like this that I played with for ages. Thanks looks like great fun.
(view all replies)Comment Reply
This is just GREAT!!!
(view all replies)Comment Reply
This is awesome.
(view all replies)Comment Reply