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

#1 2012-08-16 06:06:44

arthurz
Scratcher
Registered: 2010-02-03
Posts: 47

Code for the bounce block

Im not sure what the code is for the bounce block, is it dir - 180... im not sure. Thanks for any help


Sine wave engine, check it out.
http://www.scratch.mit.edu/projects/arthurz/2816216

Offline

 

#2 2012-08-16 06:19:25

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

Re: Code for the bounce block

arthurz wrote:

Im not sure what the code is for the bounce block, is it dir - 180... im not sure. Thanks for any help

That, or direction * -1


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

Offline

 

#3 2012-08-16 06:39:02

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Code for the bounce block

It uses a different method for each edge. For example, the code for one of the side edges is

((((direction) - 90) * (-1)) + (270))


http://i50.tinypic.com/312u714.jpg

Offline

 

#4 2012-08-16 06:42:05

BirdByte
Scratcher
Registered: 2012-07-07
Posts: 1000+

Re: Code for the bounce block

BirdByte wrote:

It uses a different method for each edge. For example, the code for one of the side edges is

((((direction) - (90)) * (-1)) + (270))

Oops, fixed. ^_^


http://i50.tinypic.com/312u714.jpg

Offline

 

#5 2012-08-16 07:10:01

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: Code for the bounce block

Taken from the Scratch Wiki:

when gf clicked
go to x: (0) y: (0)
point in direction (pick random (-179) to (180))
set [Move Speed v] to [0]
forever
move (Move Speed) steps
if <touching [edge v]?>
change x by (([sin v] of (direction)) * ((0) - (Move Speed)))
if <touching [edge v]?>
point in direction ((180) - (direction))
else
point in direction ((0) - (direction))
end
change x by (([sin v] of (direction)) * (Move Speed))
end


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

Board footer