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

#1 2012-07-07 13:23:13

DoowNimajneb
New Scratcher
Registered: 2012-06-27
Posts: 65

HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

Right, so I am making a carnival game, and my problem, is when I want the sprite          (a coin) to go to one of five sprites, and every time it touches it, to point in a random direction once, then move forwards until it hits one of seventeen sprites. I know how to make the coin move forwards until it hits one of seventeen sprites, I know how to make it go to one of five sprites, I just cant figure out how to make it point in a random direction every time it touches one of the five sprites because,
If i use the 'if' scratch block, it points in a random direction when it touches the sprite, but it only does it once and never again after that.
If I use the 'forever if' scratch block, once it touches one of the five sprites it just points in a random direction forever without stopping,

Once again please help! this project is due in on monday!
Thank you and I will check regularly so will answer any questions, suggestions or problems,
Thanks!,
DoowNimajneb

Offline

 

#2 2012-07-07 13:29:01

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

when gf clicked
forever
if <touching [sprites v]?>
point in direction (pick random (180) to (-180)) // i think that works
wait until <not <touching [sprites v]?> >

Last edited by zammer990 (2012-07-07 13:29:17)


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#3 2012-07-07 13:31:13

TRocket
Scratcher
Registered: 2009-08-18
Posts: 1000+

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

zammer990 wrote:

when gf clicked
forever
if <touching [sprites v]?>
point in direction (pick random (180) to (-180)) // i think that works
wait until <not <touching [sprites v]?> >

i think that would work, but for angles convention its best to use 0 to 360


http://i.imgur.com/1QqnHxQ.png

Offline

 

#4 2012-07-07 13:35:49

zammer990
Scratcher
Registered: 2012-01-22
Posts: 500+

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

TRocket wrote:

zammer990 wrote:

when gf clicked
forever
if <touching [sprites v]?>
point in direction (pick random (180) to (-180)) // i think that works
wait until <not <touching [sprites v]?> >

i think that would work, but for angles convention its best to use 0 to 360

Yea, I don't use angles much, and scratch turns 360 into -180 or something.


http://i45.tinypic.com/2ynq7nn.jpg Play now!

Offline

 

#5 2012-07-07 17:59:07

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

DoowNimajneb wrote:

If I use the 'forever if' scratch block, once it touches one of the five sprites it just points in a random direction forever without stopping,

That's not actually what the forever if block does. The name is slightly misleading: it is not

wait until <something happens>
forever
 do stuff
, it is actually equivalent to
forever
 if <something happens>
  do stuff
 end
There are many suggestions to remove this block because of exactly this kind of confusion. Did you actually try the forever if block?

By the way, the answer to the problem is
forever if <touching [whatever sprite you want v]?> // or forever then if as noted above
point in direction (pick a random (0) to (360)
You could also do 180 to -180; it doesn't actually matter.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

#6 2012-07-07 18:17:52

berberberber
Scratcher
Registered: 2012-03-08
Posts: 1000+

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

joefarebrother wrote:

DoowNimajneb wrote:

If I use the 'forever if' scratch block, once it touches one of the five sprites it just points in a random direction forever without stopping,

That's not actually what the forever if block does. The name is slightly misleading: it is not

wait until <something happens>
forever
 do stuff
, it is actually equivalent to
forever
 if <something happens>
  do stuff
 end
There are many suggestions to remove this block because of exactly this kind of confusion. Did you actually try the forever if block?

By the way, the answer to the problem is
forever if <touching [whatever sprite you want v]?> // or forever then if as noted above
point in direction (pick random (0) to (360))
You could also do 180 to -180; it doesn't actually matter.

fixed (your) [scripts]

Last edited by berberberber (2012-07-07 18:18:34)


http://i47.tinypic.com/2iaa73k.png

Offline

 

#7 2012-07-07 18:30:05

DoowNimajneb
New Scratcher
Registered: 2012-06-27
Posts: 65

Re: HAS TO BE IN BY MONDAY, HELP!!! always point in a random direction

i did test the 'forever if' block, thats what it did...  sad

Offline

 

Board footer