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

#1 2007-07-24 10:22:55

tilleya
Scratcher
Registered: 2007-07-24
Posts: 2

random x,y coordinates

hey guys i'm building my first program using this awsome program and i basically just need to know how to set random coordinates, so if sprite1 hits sprites 2 than sprites 2 will move to a new random location. thanks a lot.

Offline

 

#2 2007-07-24 10:24:45

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

Re: random x,y coordinates

The solution is simple, just use this block: goto x pick random -220 to 220 y pick random -220 to 220


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 2007-07-24 10:48:31

tilleya
Scratcher
Registered: 2007-07-24
Posts: 2

Re: random x,y coordinates

i dont see a goto x button,

Offline

 

#4 2007-07-24 15:32:44

paulmedwal
Scratcher
Registered: 2007-03-09
Posts: 100+

Re: random x,y coordinates

Inside of the motion category there is a "go to x: y:" block. Drag that block to the scripts area, then get two "pick a random number" block from the numbers category. Put the "pick a random number" blocks inside of the "go to x: y:" where the numbers should be. The x values go from -240 to 240 and the y values go from -180 to 180.

Paulmedwal


clutter.scratch.mit.edu Visit the Clutter site to create multi-scene stories and multi-level games with Scratch.

Offline

 

Board footer