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

#1 2012-02-09 01:10:37

Giggawatts
New Scratcher
Registered: 2012-02-09
Posts: 3

Falling objects

The idea here is simple, I want to be able to have falling objects, I've got some of it working, I can get one to fall and then go back to the top of the screen, but it's not very smooth. Also I would like to have the objects set for a random falling interval, so that they don't come out at a consistent time frame. Ideas?

Offline

 

#2 2012-02-09 01:28:55

Giggawatts
New Scratcher
Registered: 2012-02-09
Posts: 3

Re: Falling objects

Okay so I got them to cycle jut fine, any ideas of randomness?

Offline

 

#3 2012-02-09 01:35:31

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: Falling objects

the

pickrandom[10] to [20]
block


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#4 2012-02-09 02:05:34

Giggawatts
New Scratcher
Registered: 2012-02-09
Posts: 3

Re: Falling objects

And that is in seconds?

Offline

 

#5 2012-02-09 03:07:47

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Falling objects

go to x: (pick random [-240] to [240]) y: [180]
glide (pick random [3] to [5]) secs to x: (x position) y: [-180]

Last edited by RedRocker227 (2012-02-09 03:08:21)


Why

Offline

 

#6 2012-02-10 17:23:27

egrizzly
New Scratcher
Registered: 2012-02-10
Posts: 4

Re: Falling objects

The CS instructor addressed this at some point.  You have to use a forever loop to get the objects to appear at random locations on the "x" axis at a fixed location in the "y" axis, then gradually decrease their "y" value (their distance to the ground).

Use the "pick random" module in the Operators section for the place of the x value (of course you have to set the range of the x-plane where the object appears

goto x: (pick random [-100 to 100]) y: [150]
 when gf clicked
forever
    change y by [-1]
 

Offline

 

#7 2012-02-10 17:26:43

egrizzly
New Scratcher
Registered: 2012-02-10
Posts: 4

Re: Falling objects

egrizzly wrote:

The CS instructor addressed this at some point.  You have to use a forever loop to get the objects to appear at random locations on the "x" axis at a fixed location in the "y" axis, then gradually decrease their "y" value (their distance to the ground).

I corrected the scratch blocks graphics. my bad.



when gf clicked
goto x: (pick random [-100 to 100]) y: [150]
forever
    change y by [-1]
 

Offline

 

#8 2012-02-10 17:38:08

egrizzly
New Scratcher
Registered: 2012-02-10
Posts: 4

Re: Falling objects

egrizzly wrote:

egrizzly wrote:

The CS instructor addressed this at some point.  You have to use a forever loop to get the objects to appear at random locations on the "x" axis at a fixed location in the "y" axis, then gradually decrease their "y" value (their distance to the ground).

I corrected the scratch blocks graphics. my bad.



when gf clicked
goto x: (pick random [-100 to 100]) y: [150]
forever
    change y by [-1]
 

by the way...you have to do this for each falling object.  To set the falling interval just use the "wait x seconds" after the "change y by -1" statement to vary the timing of the fall between the sprites/objects.  You have to change the # of seconds in each "wait../." statement for each sprite/object.

Offline

 

Board footer