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

#1 2010-09-23 10:12:10

dogwasp
Scratcher
Registered: 2010-08-31
Posts: 11

bouncing

how do you make a sprete bounce off a color


come to the dark side
we have cookies  big_smile

Offline

 

#2 2010-09-23 10:18:33

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: bouncing

Not a advanced topic


You can now reach me on Twitter @johnnydean1_

Offline

 

#3 2010-09-23 10:40:23

ProgrammingFreak
Scratcher
Registered: 2010-09-04
Posts: 1000+

Re: bouncing

Its quite simple!

Offline

 

#4 2010-09-26 00:52:24

bbbeb
Scratcher
Registered: 2009-06-11
Posts: 1000+

Re: bouncing

<if <touching color [bounce color]>>
turn (direction-180)degrees
move (number) steps.

Now mods, please close this.  big_smile


Back in my day.... there were no laws that censored the internet... now, there are.... nah.

Offline

 

#5 2010-09-26 03:26:48

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: bouncing

bbbeb wrote:

<if <touching color [bounce color]>>
turn (direction-180)degrees
move (number) steps.

Now mods, please close this.  big_smile

I wouldn't really say that's the BEST way of bouncing, you should right add the direction bouncing like the scratch block "if on edge, bounce" does. I can't remember what the math formula is exactly, though...

Last edited by LS97 (2010-09-26 03:27:57)

Offline

 

#6 2010-09-26 10:26:54

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: bouncing

LS97 wrote:

bbbeb wrote:

<if <touching color [bounce color]>[/blocks]>
turn (direction-180)degrees
move (number) steps.

Now mods, please close this. :D

I wouldn't really say that's the BEST way of bouncing, you should right add the direction bouncing like the scratch block "if on edge, bounce" does. I can't remember what the math formula is exactly, though...

I think MathWizz (:P) had a project for doing this.

Last edited by nXIII (2010-09-26 10:27:20)


nXIII

Offline

 

#7 2010-09-26 10:39:58

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: bouncing

nXIII wrote:

LS97 wrote:

bbbeb wrote:

<if <touching color [bounce color]>[/blocks]>
turn (direction-180)degrees
move (number) steps.

Now mods, please close this.  big_smile

I wouldn't really say that's the BEST way of bouncing, you should right add the direction bouncing like the scratch block "if on edge, bounce" does. I can't remember what the math formula is exactly, though...

I think MathWizz ( tongue ) had a project for doing this.

well, really all of the projects that use bouncing which is not on edge have it. even I made one once....

Offline

 

#8 2010-09-26 14:01:55

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

Re: bouncing

nXIII wrote:

LS97 wrote:

bbbeb wrote:

<if <touching color [bounce color]>[/blocks]>
turn (direction-180)degrees
move (number) steps.

Now mods, please close this.  big_smile

I wouldn't really say that's the BEST way of bouncing, you should right add the direction bouncing like the scratch block "if on edge, bounce" does. I can't remember what the math formula is exactly, though...

I think MathWizz ( tongue ) had a project for doing this.

I've got one too, right here.  It does bouncing off of horizontal and vertical surfaces.  If you want inclined surfaces, things get more complicated, but I do have some examples here and there, if you are interested.


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

Offline

 

#9 2010-09-26 14:15:19

nXIII
Community Moderator
Registered: 2009-04-21
Posts: 1000+

Re: bouncing

Paddle2See wrote:

nXIII wrote:

LS97 wrote:


I wouldn't really say that's the BEST way of bouncing, you should right add the direction bouncing like the scratch block "if on edge, bounce" does. I can't remember what the math formula is exactly, though...

I think MathWizz ( tongue ) had a project for doing this.

I've got one too, right here.  It does bouncing off of horizontal and vertical surfaces.  If you want inclined surfaces, things get more complicated, but I do have some examples here and there, if you are interested.

Yea, I was referring to this project. It has a few glitches, but it does things pretty well.


nXIII

Offline

 

#10 2010-10-02 05:40:43

subzerostig
Scratcher
Registered: 2010-09-08
Posts: 100+

Re: bouncing

Its simple!!!
If you want it to bounce off a verticle surface use this code

<when green flag clicked>
<forever>
<if><touching[ sprite1 ]
<point in direction( ((<direction>  <*>-1  ))
<wait until><<  <not><touching[ sprite 1]  >>
<end>

To bounce off a horizontal surface instead of point in direction direction * -1
say: point in direction direction * -1 -180

hope it helps  smile


There are 10 types of people people in this world, those that understand binary and those that do not: My latest Project: Present catcher V2                          06/12/2012

Offline

 

#11 2010-10-02 05:55:52

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: bouncing

When Flag Clicked
forever
[
if <touching wall>
[
point in direction ( 0 - (direction) )
repeat until < not <touching wall> >
[
move 3 steps
]
]
]


You can now reach me on Twitter @johnnydean1_

Offline

 

#12 2010-10-03 20:56:33

platform710
Scratcher
Registered: 2010-04-23
Posts: 100+

Re: bouncing

to make a realistic bounce, make a variable called "y velocity" then put "forever: if touching color( ) or sprite ( ): set velocity to 15 or whatever you choose. then outside of the if loop,  change velocity by : -1  change Y by velocity. put all that in a forever loop. hope that helps  smile


http://i54.tinypic.com/2wn8hnb.gif

Offline

 

Board footer