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

#1 2012-01-30 21:37:10

MathMaster101
Scratcher
Registered: 2011-10-29
Posts: 100+

how to make sprite move in different directions in random order

Does anyone know how to make an sprite move in different directions in random order?
Also, does anyone know how to make a sprite bounce off of a sprite it just touched?


https://sphotos.xx.fbcdn.net/hphotos-snc6/c39.0.403.403/p403x403/196165_191956434263692_1014187386_n.jpg

Offline

 

#2 2012-01-30 21:54:52

Mokat
Scratcher
Registered: 2011-12-08
Posts: 1000+

Re: how to make sprite move in different directions in random order

do this:

 when gf clicked
wait <pick random (1) to (10)> secs 
 go to x: <pick random (1) to (10)> y: <pick random (1) to (10)> 
Of course, you could put in different numbers.

Last edited by Mokat (2012-01-30 21:56:04)


http://www.eggcave.com/egg/977371.pnghttp://www.eggcave.com/egg/977376.pnghttp://www.eggcave.com/egg/1005291.pnghttp://www.eggcave.com/egg/996745.png

Offline

 

#3 2012-01-31 00:30:13

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

Re: how to make sprite move in different directions in random order

when gf clicked
go to (0) (0)
point in direction (0)
forever
    point in direction <(direction) + <pick random (-10) to (10)>>
    move (5) steps
Though the movement would be quite random and confusing. I'm sure there is a way to optimize the script so the object has a little more "focused" movement rather than turning in random directions without any "real intent", unless of course, you want it to be really odd. The "focused" movement is more for AIs, I guess.

Bouncing is probably one of the more complicated scripts in programming and for that, I'm not entirely sure.

Offline

 

#4 2012-01-31 02:38:06

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: how to make sprite move in different directions in random order

To bounce an object off another:

when gf clicked
forever
  if <touching [whateversprite v] ?>
    turn cw ((180)-(direction)) degrees
  end
end

Last edited by fg123 (2012-01-31 02:40:14)


Hai.

Offline

 

#5 2012-02-01 03:21:04

fetchydog567
Scratcher
Registered: 2011-12-28
Posts: 500+

Re: how to make sprite move in different directions in random order

Here is to make it move when you click the sprite.

<when[Sprite1]clicked>
<glide(1)secs to x:<pick random(-90)to(900)to y:<pick random(-90)to(900)>
Also in my project Click-Ball.


http://www.minecraftanonymous.com/assets/banners/banner_51.pngJust a reminder I won't be on Scratch that much but I 'll still be here, so if i'm on something, I will be commenting back, okay! wink , PICO Team!!!!!!!!!!! SCRATCH DEADW!!! PICO HACK ACCOUTNTT@@

Offline

 

#6 2012-02-01 04:19:33

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

Re: how to make sprite move in different directions in random order

fetchydog567 wrote:

Here is to make it move when you click the sprite.

when[Sprite1]clicked
glide(1)secs to x:(pick random(-90)to(900)) y:(pick random(-90)to(900))
Also in my project Click-Ball.

Fixed script.

Offline

 

#7 2012-02-02 22:07:07

360-International
Scratcher
Registered: 2011-07-17
Posts: 100+

Re: how to make sprite move in different directions in random order

Magnie wrote:

when flag clicked
go to x: (0) y: (0)
point in direction (0)
forever
point in direction ((direction) + (pick random (-10) to (10)))
move (5) steps
Though the movement would be quite random and confusing. I'm sure there is a way to optimize the script so the object has a little more "focused" movement rather than turning in random directions without any "real intent", unless of course, you want it to be really odd. The "focused" movement is more for AIs, I guess.

Bouncing is probably one of the more complicated scripts in programming and for that, I'm not entirely sure.

Fixed.


https://lh4.googleusercontent.com/Oib6kyze-OrCFIRlqL6HYnWuHBQp1GfFoh5CkBlZGe3_9WCk-_DDwgfFrnD_mxJ_x2b18hMUyV2KVtIDiLdebyWaQQ6fbpKpZs-8auVep1zoSgOv-iA

Offline

 

Board footer