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

#1 2009-04-20 08:35:18

SBLOVI01
Scratcher
Registered: 2009-04-20
Posts: 3

How do I...

How do I get the sprites to move randomly across the screen? Do I have to just put a lot of scripts, or can they just randomly glide places? If this is possible, how do I do it?

Offline

 

#2 2009-04-20 08:38:31

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: How do I...

forever
turn (pick random 1 to 360) degrees
repeat(pick random 1 to 100){
move 1
}


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#3 2009-04-20 14:13:30

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: How do I...

[blocks]
<when green flag clicked>
<forever>
<glide( <pick random( 1 )to( 10 )) )secs to x sad  <pick random( -300 )to( 300 )y sad  <pick random( -300 )to( 300 >
<end>

Offline

 

#4 2009-04-20 17:21:21

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

Re: How do I...

Magnie wrote:

[blocks]
<when green flag clicked>
<forever>
<glide( <pick random( 1 )to( 10 )) )secs to x sad  <pick random( -300 )to( 300 )y sad  <pick random( -300 )to( 300 >
<end>

This is a pretty good script...but you are going outside the range of the Scratch screen ( X goes from -240 to 240 and Y goes from -180 to 180) so your sprite will spend a fair amount of time at the edges of the screen because of the out of bound values.  You may want to limit X and Y to the values I give here, if you don't want the sprite hanging out at the edges a lot  smile


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

Offline

 

#5 2009-04-20 17:33:28

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: How do I...

I didn't know what the screen range was...

Offline

 

#6 2009-04-21 08:40:16

SBLOVI01
Scratcher
Registered: 2009-04-20
Posts: 3

Re: How do I...

Thanks! This helps alot.

Offline

 

#7 2009-04-21 10:09:03

Magnie
Scratcher
Registered: 2007-12-12
Posts: 1000+

Re: How do I...

Your welcome.  smile

Offline

 

Board footer