Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Bouncing how?
- vinians
- New to Scratch
20 posts
Bouncing how?
Hi guys! I know I can bounce when the sprite hit boundary but how can I bounce when my sprite hit a wall for example? What formula can I use for it?
- scubajerry
- Scratcher
1000+ posts
Bouncing how?
http://scratch.mit.edu/projects/12004820/
You will just me messing with the X parameters instead of the Y
You can make the wall part of the backdrop, or a sprite.
You will just me messing with the X parameters instead of the Y
You can make the wall part of the backdrop, or a sprite.
Last edited by scubajerry (Oct. 11, 2013 15:28:58)
- vinians
- New to Scratch
20 posts
Bouncing how?
Its not that simple… I need a way to bounce accord to the angle like a mirror reflexion of a laser!
see in “dl.dropboxusercontent.com/u/16702799/images/bounce.png”
My wall is a sprite already, but I want my another sprite bounce when collide with wall sprite, I know theres a calculation but I dont remember !
see in “dl.dropboxusercontent.com/u/16702799/images/bounce.png”
My wall is a sprite already, but I want my another sprite bounce when collide with wall sprite, I know theres a calculation but I dont remember !
- scubajerry
- Scratcher
1000+ posts
Bouncing how?
If you are moving in a direction, set the new direction ito 180-direction
If you are using Y velocity and X velocity you do it like this http://scratch.mit.edu/projects/13152873/
If you are using Y velocity and X velocity you do it like this http://scratch.mit.edu/projects/13152873/
Last edited by scubajerry (Oct. 11, 2013 15:52:23)
- scubajerry
- Scratcher
1000+ posts
Bouncing how?
Are you drawing the path, or just having an object bounce?
- vinians
- New to Scratch
20 posts
Bouncing how?
Just an object fired by a cannon which sometime will bounce against a wall, Im using direction.
Thanks!
Thanks!
- scubajerry
- Scratcher
1000+ posts
Bouncing how?
One problem with bouncing is when your sprite hits two walls at the same time in a corner. Here is a solution to that.Do you mean for the ball to bust right out of the box? It does.
- pedro_pete
- Scratcher
4 posts
Bouncing how?
Do you want to assume perfect bounciness (no loss of speed)?
- Locomule
- Scratcher
1000+ posts
Bouncing how?
It was fine on my pc. I made the ball speed ajustable. If it leaves the box, restart it and slow it down 1 speed. Eventually it should run fine. The point is that the method works. I could have made the wall thicker but I wanted to prove that the system works on its own.
Likewise, if you start it and the ball stays inside, try speeding it up. I made it deafault to 6 which is half as fast as my pc will run it correctly.
Likewise, if you start it and the ball stays inside, try speeding it up. I made it deafault to 6 which is half as fast as my pc will run it correctly.
- Locomule
- Scratcher
1000+ posts
Bouncing how?
ps. Most Scratch problems do not have a bulletproof solution. If I increase the ball speed too much, I will have to increase the wall thickness, add more check loops, or maybe use a different method, like using 4 sprites for the walls. Or adding a feeler sprites. Or backing the ball up after contact, etc. Even the most stable method may have to be replaced or altered as your project grows.
- Discussion Forums
- » Help with Scripts
- » Bouncing how?