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

#1 2012-05-28 12:57:29

thunderfoot22
New Scratcher
Registered: 2012-05-23
Posts: 1

Random falling scripts

Please help - I am trying to make scripts fall randomly from the sky.  If they touch the character script the counter will go up.  If they miss the character and hit the floor they will splat.  How to I get their movement???

Offline

 

#2 2012-05-28 13:20:09

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Random falling scripts

This should help,

when gf clicked
forever
go to x: (pick random [-250] to [250]) y: (180)
glide(5)seconds to x:(x position) y:(-130)
if <touching [sprite 1 v]?>
change [counter v] by [1]
else
switch to costume [splat v]
end
wait (pick random [1] to [10]) secs

Last edited by sonicfan12p (2012-05-28 14:24:35)


Why are the secret organizations getting all the attention?  mad

Offline

 

#3 2012-05-28 13:32:25

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: Random falling scripts

I have a project that uses a similar mechanism, except with x, not y: Space shooter
You could download it and look at the meteor scripts.


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#4 2012-05-28 13:46:58

wasabi56
Scratcher
Registered: 2012-02-10
Posts: 500+

Re: Random falling scripts

sonicfan12p wrote:

This should help,

when gf clicked
forever
go to x:(pick random [-250] to [250])y:(180)
glide(5)secs to x:(x position)y:(-130)
if <touching [sprite 1 v]?>
change [counter v] by [1]
else
switch to costume [splat v]
end
wait (pick random [1] to [10]) secs

Fixed  smile


http://i.picasion.com/pic58/c23d4d2fc75f459dcf3d9ebf3e8ba395.gif
http://www.weebly.com/uploads/1/0/1/4/10146167/2294523_orig.png

Offline

 

#5 2012-05-28 13:51:13

SciTecCf
Scratcher
Registered: 2011-11-23
Posts: 1000+

Re: Random falling scripts

You could use this:

when gf clicked
forever
 go to x: (pick random (-220) to (220)) y: (170)
 set [newcoin v] to [0]
 repeat until <(newcoin) = [1]>
  change y by (-2)
  if <touching [Player v]?> //Your player sprite.
   set [newcoin v] to [1]
   change [score v] by (1)
  end
  if <touching [Ground v]?> //Your ground sprite. Touching edge will work too.
   set [newcoin v] to [1]
  end
 end
end

Last edited by SciTecCf (2012-05-28 13:52:05)


http://bit.ly/LCZEJRhttp://bit.ly/LSONcOhttp://bit.ly/LF3vIc
http://trinary.site40.net/images/scratchrank.php?username=SciTecCf&amp;display=small

Offline

 

#6 2012-05-28 14:25:19

sonicfan12p
Scratcher
Registered: 2011-11-16
Posts: 1000+

Re: Random falling scripts

wasabi56 wrote:

sonicfan12p wrote:

This should help,

when gf clicked
forever
go to x:(pick random [-250] to [250])y:(180)
glide(5)secs to x:(x position)y:(-130)
if <touching [sprite 1 v]?>
change [counter v] by [1]
else
switch to costume [splat v]
end
wait (pick random [1] to [10]) secs

Fixed  smile

Thanks!


Why are the secret organizations getting all the attention?  mad

Offline

 

Board footer