I don't fully understand, but for the hill
[blocks]<when green flag clicked>[/blocks]
[blocks]<forever if><touching color>[Hill color>[/blocks]
[blocks]<change y by(2[/blocks]
And vice versa for down. For the Sig, go to profile>personality
Last edited by Bluestribute (2008-04-28 22:13:02)
Offline
oh. Dunno. Sorry
Offline
and if the slope was vertical it would bounce left and so on and maybe bounce different amounts depending on y speed and x speed for the other part I meant if you move tward a slope while on the ground when you got to the slope you would go up it if that makes any sense
Offline
Here is a project you might want to look at by EdnaC. There was a similar question on the Forum awhile back asking how you might program a ball for realistic bouncing off of slopes at various angles. It is not an easy problem.
http://scratch.mit.edu/projects/EdnaC/102490
Offline
would you mind explaining how that program works i cant quite figure out what the different variables do especially why ednac used the variable <{ travel direction }>
instead of <direction> they seem to always be the same
Offline
If I recall correctly, "TravelDirection" was used to store the "direction" that the sprite was moving when it struck the wall. After that, the sprite turns to find the slope of the wall, so without the variable, its original direction would be forgotten. Once the slope is found, the original travel direction and the slope are used to calculate the new direction. Vectors are used to do the math, Canthiar has an excellent tutorial on the "reflection vector".
Bouncing ball also uses the spin of the ball to alter the new direction. It's a pretty complicated project, and may be more than what you are after. Things get much easier if what you hit has a known angle.
Perhaps you could describe in more detail what you are trying to do?
-MrEd
Offline
thanks what I was mainly trying to do is when the ball falls on a slope have it bounce a couple times and roll downhill my problem is getting it to bounce when it falls on a hill but not when it rolls up a hill I also have trouble making it bounce higher when it is falling faster
Offline
If the slope can be a straight line or series of straight lines that is formed of multiple sprites, the problem becomes much easier and you can do a project that runs more smoothly, as you don't need to "probe" to find the slope in the way BouncingBall does.
Paddle2See did a Put-Put Golf project that uses sprites as the walls that the ball bounces from. The same vector math approach is used to determine the reflection angle, but the slope can just be gotten from the sprite that the ball hit. You may want to examine that project for ideas, adding gravity would give you something like what you are describing.
-MrEd
Offline
EdnaC wrote:
Paddle2See did a Put-Put Golf project that uses sprites as the walls that the ball bounces from. The same vector math approach is used to determine the reflection angle, but the slope can just be gotten from the sprite that the ball hit. You may want to examine that project for ideas, adding gravity would give you something like what you are describing.
-MrEd
Right, that would be pretty close... here's the link
http://scratch.mit.edu/projects/Paddle2See/82463
and I got the technique from Kevin_and_Abe's School Pinball project which is here
http://scratch.mit.edu/projects/kevin_and_abe/54377
Offline