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

#1 2008-01-14 20:27:55

eolelake
Scratcher
Registered: 2007-12-01
Posts: 2

Randomly dropping

I really need help on this. How do you get a sprite to randomly drop from the top of your graph/screen? Please help me out I'm really stuck. I know it has something to do with picking random numbers and motion

Offline

 

#2 2008-01-15 01:37:41

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Randomly dropping

Hi eolelake,

I'm not sure I understand your question. I'm assuming that by "randomly dropping" you are suggesting, that a sprite will start at a different location each time it moves from the top of the Scratch stage to the bottom.

You could start out by coding something like this for your 'dropping' sprite:

[blocks]
<when green flag clicked>
<forever>
  <go to x sad  <pick random( -240 )to( 240 )y sad  200
  <repeat until><( <y position> <<> -180 )>
   <change y by( -5
   <wait( 0.1 )secs>
  <end>
<end>
[/blocks]

(okay, I've had it, these forum blocks are horribly buggy and frustrating!)

This should make your sprite move in a straight line from the stage's top to the bottom at a fixed speed.

Then you could experiment with the numbers to make the sprite go faster or slower, and add some other movements to - maybe - increase the sprite's speed as it keeps falling ('gravity') or to also make it go sideways.

Did that help?


Jens Mönig

Offline

 

Board footer