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

#1 2007-07-08 11:48:59

donkeyscommand
Scratcher
Registered: 2007-06-03
Posts: 10

Scramble Sprites?

How do I get Sprites to switch places when the Green Flag is pressedso they go to a random place? Need it for a Deal Or No Deal game with boxes that change places.

Offline

 

#2 2007-07-08 12:01:53

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Scramble Sprites?

when green flag
     goto 50*(random from 1 to 7   - 3) , 50*random from 1 to 3

Offline

 

#3 2007-07-08 13:26:13

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Scramble Sprites?

The hard part would be making sure only one box ended up in one place.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#4 2007-07-08 17:16:51

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Scramble Sprites?

Ah, sorry.  I hadn't realized it was a permutation question.  That is a bit harder in scratch, since there are no arrays.  If there are small number of sprites, you could have them find places one a time:

   sprite 1 :
       On green flag
       go to random box
       broadcast place2

   sprite2:
      when I receive place2
      goto random box
      repeat until not touching color (color on all sprites)
         goto random box
     broadcast place3

(all the subsequent sprites are like sprite2, but with the numbers incremented by one)
The "goto random box" should be replaced by the appropriate goto command.

Offline

 

#5 2008-09-26 12:48:26

Marine43753
Scratcher
Registered: 2008-08-25
Posts: 16

Re: Scramble Sprites?

put this in all the the sprites you want to scramble.....[blocks]<when green flag clicked>(<forever><wait( 3 )secsc><go to x sad  <pick random( -200 )to(  200)y sad  <pick random( -200 )to( 200)[/blocks]



hope that helps  smile

Offline

 

Board footer