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

#1 2012-07-21 03:39:55

Jonas13
New Scratcher
Registered: 2012-07-15
Posts: 3

How to program left OR right?

Can you program an object so that it goes to the left or right?
If one assumes random number/"pick random", it's all still up or diagonally.
If so, how?

<pick random(  hmm

Thanks for help!  wink

Offline

 

#2 2012-07-21 03:57:31

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: How to program left OR right?

Jonas13 wrote:

Can you program an object so that it goes to the left or right?
If one assumes random number/"pick random", it's all still up or diagonally.
If so, how?

<pick random(  hmm

Thanks for help!  wink

I don't really understand what you're trying to say... maybe give a visual example?


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#3 2012-07-21 14:19:13

XXtitaniumfangXX
New Scratcher
Registered: 2012-07-12
Posts: 57

Re: How to program left OR right?

when gf clicked
change x by <pick random>
that may or may not work

Offline

 

#4 2012-07-21 15:08:06

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

Re: How to program left OR right?

when gf clicked
set [direction v] to (pick random (1) to (2))
if <(direction) = (1)>
change x by (10)
else
change x by (-10)


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

Offline

 

#5 2012-07-21 15:11:26

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

Re: How to program left OR right?

zammer990 wrote:

when gf clicked
set [direction v] to (pick random (1) to (2))
if <(direction) = (1)>
change x by (10)
else
change x by (-10)

Simpler:

when gf clicked
if <(pick random (1) to (2)) = (1)>
change x by (10)
else
change x by (-10)
smile


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

Offline

 

#6 2012-07-21 15:40:10

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: How to program left OR right?

this is how I do it

point in direction ((((pick random (0) to (1)) * (2)) - (1)) *(90))
move (10) steps // picks -90 or 90

Last edited by Wes64 (2012-07-21 15:40:53)


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

Board footer