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

#1 2012-04-19 22:10:42

jgpayne
New Scratcher
Registered: 2012-04-19
Posts: 1

School Project

I need help making the y values of my sprites appear in one of four random spots, but keep the x value the same.

Thanks for the help!

Offline

 

#2 2012-04-19 22:17:38

trinary
Scratcher
Registered: 2012-01-29
Posts: 1000+

Re: School Project

Make a list with the random y values.

Use:

go to x:
0
y:
item
pick random
1
to
length of
yvalues
of
yvalues

Replace the x value with your desired value.


http://trinary.tk/images/signature_.php

Offline

 

#3 2012-04-19 22:29:00

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: School Project

Hmm.... here's one method I came up with.

when clicked
Give this script to the stage.
delete
all
of
y values
add
-150
to
y values
add
-50
to
y values
add
50
to
y values
add
150
to
y values
broadcast
sprite 1
and wait
broadcast
sprite 2
and wait
broadcast
sprite 3
and wait
broadcast
sprite 4
and wait
when I receive
sprite 1
Give this to each sprite, but use different names
set
random
to
pick random
1
to
length of
y values
go to x:
0
y:
item
random
of
y values
delete
random
of
y values

I basically used the script trinary posted, but extended it with all of the blocks that are needed for the project.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#4 2012-04-20 05:43:41

rings
New Scratcher
Registered: 2012-04-20
Posts: 1

Re: School Project

in which language?

Offline

 

#5 2012-04-20 06:36:15

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: School Project

rings wrote:

in which language?

Hello, rings! Discussion in this forum is specifically for the Scratch programming language, so all questions here will be referring to Scratch.  smile

Offline

 

Board footer