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

#1 2012-07-08 10:15:25

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Bouncing in a scroller

I'm making a top-down scrolling game with velocity. How would I make the main sprite bounce  off of a color in the background? Meaning, what would the "bounce" be in:

when gf clicked
forever
if <touching color [ ]?>
bounce
end
end
Thanks!


http://i48.tinypic.com/2072ctw.gif

Offline

 

#2 2012-07-08 10:37:31

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: Bouncing in a scroller

just have it so when it's touching the colour, the velocities are inverted


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-07-08 10:42:56

powerpoint56
Scratcher
Registered: 2012-04-19
Posts: 500+

Re: Bouncing in a scroller

Great, thanks!


http://i48.tinypic.com/2072ctw.gif

Offline

 

#4 2012-07-09 09:13:43

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Bouncing in a scroller

If it's touching the color that defines walls that run left-to-right (walls that block vertical movement) multiply y velocity by -1 (or by some number a little closer to 0, like -0.5, if you want some velocity to go away).  If it's touching the color that defines walls that run up-to-down (walls that block horizontal movement) multiply the x velocity by the same number (either -1 or something like that).

Offline

 

Board footer