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

#1 2008-04-28 21:30:02

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

accurate movement on slopes

Im making a game that involves a marble going up and down slopes and off jumps in two directions  does anyone have a script to do this

Also it needs to bounce in an accurate direction when it falls on a slope

Offline

 

#2 2008-04-28 21:33:30

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

ps can someone help me figure out how to edit my signature

Offline

 

#3 2008-04-28 22:12:19

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: accurate movement on slopes

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)


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#4 2008-04-28 22:47:49

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

sorry i meant if the hill is at a forty five degree angle then the marble would have to bounce sideways

Offline

 

#5 2008-04-28 22:52:06

Bluestribute
Scratcher
Registered: 2008-01-24
Posts: 1000+

Re: accurate movement on slopes

oh. Dunno. Sorry


http://img247.imageshack.us/img247/1204/bluestributett4.jpg
That's my PSN ID. I know tons of COD4 glitches. Add me as your friend. Oh, and get a headset

Offline

 

#6 2008-04-28 22:56:14

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

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

 

#7 2008-04-28 22:58:36

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

thanks for the help with the signature

Offline

 

#8 2008-04-29 04:08:31

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: accurate movement on slopes

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


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#9 2008-04-29 22:09:49

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

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

 

#10 2008-04-30 12:04:59

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: accurate movement on slopes

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

 

#11 2008-04-30 21:20:49

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

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

 

#12 2008-05-01 07:19:10

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: accurate movement on slopes

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

 

#13 2008-05-01 16:01:03

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: accurate movement on slopes

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


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#14 2008-05-02 22:01:34

pbscratch
Scratcher
Registered: 2008-04-23
Posts: 8

Re: accurate movement on slopes

Thanks i think it will probably work ill post the game when i finish

Offline

 

Board footer