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

#1 2012-06-27 14:21:41

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

Gliding Randomly! HELP!

All right, so I am making a carnival game in scratch, and i am struggling on making the coin move in a random direction.
So far I have:

when I receive [broadcasted thing]
Point in direction <Pick random (1) to (180)>
The 'broadcasted thing' is just a name I gave a broadcast.

Now I need to make it move forwards until it hits a sprite, but I need to be able to see it so it needs to be a 'glide' block, but this coin needs to move forwards whichever direction it is facing.
If you need any more information, have a question or have a solution, please post it and I will check regularly and answer anything.

Please Help!!!

Offline

 

#2 2012-06-27 14:29:47

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: Gliding Randomly! HELP!

repeat until <touching [board v]?>
 move (2) steps
end
It should show you it moving. You can change the 2 for a different number (higher moves faster).

Offline

 

#3 2012-06-27 20:45:52

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Gliding Randomly! HELP!

you would do somthing like this  big_smile

when I receive [broadcasted thing v]
glide (1) secs to x: (Pick random (1) to (360)) y: (pick random (1) to (360))
wait until <touching [board v]?>
This is an alternative to Scimonster script, his would work, but if you want a really smooth and consistant glide use this script  big_smile

Last edited by daniel_j (2012-06-28 07:59:30)


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#4 2012-06-28 05:52:02

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

Re: Gliding Randomly! HELP!

daniel_j wrote:

you would do somthing like this  big_smile

when I receive [broadcasted thing v]
glide (1) secs to x: (Pick random (1) to (360)) y: (pick random (1) to (360))
wait until <touching [board v]?>
This is a code you could use, sorry for my terrible scratch blocks xD

Fixed.


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

Offline

 

#5 2012-06-28 07:54:25

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Gliding Randomly! HELP!

SciTecCf wrote:

daniel_j wrote:

you would do somthing like this  big_smile

when I receive [broadcasted thing v]
glide (1) secs to x: (Pick random (1) to (360)) y: (pick random (1) to (360))
wait until <touching [board v]?>
This is a code you could use, sorry for my terrible scratch blocks xD

Fixed.

Thanks again SciTecCf xD huge help  big_smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#6 2012-06-28 09:28:16

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

Re: Gliding Randomly! HELP!

scimonster wrote:

repeat until <touching [board v]?>
 move (2) steps
end
It should show you it moving. You can change the 2 for a different number (higher moves faster).

Will this script move smoothly or will it appear jittery?
Also, how can I get this to work for multiple sprites because it needs to top if it hits one of seventeen sprites. I am not bothered if I will have to keep repeating the same script for different sprites, I just want to know if this will work (well).

Offline

 

#7 2012-06-28 18:06:45

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Gliding Randomly! HELP!

DoowNimajneb wrote:

scimonster wrote:

repeat until <touching [board v]?>
 move (2) steps
end
It should show you it moving. You can change the 2 for a different number (higher moves faster).

Will this script move smoothly or will it appear jittery?
Also, how can I get this to work for multiple sprites because it needs to top if it hits one of seventeen sprites. I am not bothered if I will have to keep repeating the same script for different sprites, I just want to know if this will work (well).

It won't appear too jittery, but there's a better script to use if you're detecting 17 sprites.

If you make a list, for example called "SpriteList", add the names of all 17 sprites into the list, then do:
http://img151.imageshack.us/img151/6812/anyspritelist.gif


Hai.

Offline

 

#8 2012-06-29 02:23:58

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

Re: Gliding Randomly! HELP!

Thanks!
Look like this is going to work perfectly!
Thanks to everyone who helped me!

Offline

 

#9 2012-06-29 02:31:25

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Gliding Randomly! HELP!

Maybe you should request for the thread to be locked, as it has reached its purpose xD Joy to help! !

Last edited by daniel_j (2012-06-29 02:32:27)


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#10 2012-06-29 12:41:23

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

Re: Gliding Randomly! HELP!

how do I request for the thread to be locked?

Offline

 

#11 2012-06-29 12:54:34

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Gliding Randomly! HELP!

You click the "report" button on the first post, and tell the Scratch Team: "The problem is solved, please close this thread." And you're done!

Have fun, eat your vegetables, and Scratch On!


Hai.

Offline

 

#12 2012-06-29 13:14:51

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Gliding Randomly! HELP!

fg123 wrote:

It won't appear too jittery, but there's a better script to use if you're detecting 17 sprites.

If you make a list, for example called "SpriteList", add the names of all 17 sprites into the list, then do:
http://img151.imageshack.us/img151/6812/anyspritelist.gif

I'm afraid that won't work.  The (any v) value just selects a random member from the list, rather than actually returning every member of the list.  This would sometimes return true and sometimes return false if the object were touching another sprite.  Sorry.

Last edited by amcerbu (2012-06-29 13:16:06)

Offline

 

#13 2012-06-29 13:19:12

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

Re: Gliding Randomly! HELP!

Well then how can I get it to work then!

Offline

 

#14 2012-06-29 13:22:13

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

Re: Gliding Randomly! HELP!

Sorry, meant to put ? Instead of !

Offline

 

#15 2012-06-29 15:42:34

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

Re: Gliding Randomly! HELP!

You could iterate through the list, but that would be slow.


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

Offline

 

#16 2012-06-29 17:23:37

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Gliding Randomly! HELP!

amcerbu wrote:

fg123 wrote:

It won't appear too jittery, but there's a better script to use if you're detecting 17 sprites.

If you make a list, for example called "SpriteList", add the names of all 17 sprites into the list, then do:
http://img151.imageshack.us/img151/6812 … telist.gif

I'm afraid that won't work.  The (any v) value just selects a random member from the list, rather than actually returning every member of the list.  This would sometimes return true and sometimes return false if the object were touching another sprite.  Sorry.

Really, I recall that it worked back then. Let me test it...

EDIT: It doesn't select a random one, it actually iterates through the list at super speed.

It does do the detection though, so it works. Try it.

Last edited by fg123 (2012-06-29 17:23:57)


Hai.

Offline

 

#17 2012-06-29 17:59:21

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Gliding Randomly! HELP!

I did try it.  Here's the link:

http://scratch.mit.edu/projects/ubrecma/2644346

Notice that, even when the red cat is touching another cat, the variable "flickers", depending on which member of the list the "item (any)" block has selected.

Offline

 

#18 2012-06-29 19:46:01

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

Re: Gliding Randomly! HELP!

amcerbu wrote:

fg123 wrote:

It won't appear too jittery, but there's a better script to use if you're detecting 17 sprites.

If you make a list, for example called "SpriteList", add the names of all 17 sprites into the list, then do:
http://img151.imageshack.us/img151/6812 … telist.gif

I'm afraid that won't work.  The (any v) value just selects a random member from the list, rather than actually returning every member of the list.  This would sometimes return true and sometimes return false if the object were touching another sprite.  Sorry.

IF you're constantly looping over it then it gives a fairly useable result


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

Offline

 

#19 2012-06-30 04:08:38

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Gliding Randomly! HELP!

^^Not really...

Let's say there are 100 objects on the screen, meaning 100 items in the list to check.  The main object will move, and every frame, will check if it is touching a random 1 of these 100.  That means that if it is actually touching a specific object, there is only a 1/100 (1%) chance that it will register collision with that object.

I don't think that this project will be using 100 sprites (maybe 15 is a reasonable guess) but that's still only about a 7% accuracy rate.

Last edited by amcerbu (2012-06-30 04:09:51)

Offline

 

#20 2012-06-30 05:27:55

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Gliding Randomly! HELP!

I thought this post was about random gliding, not involving lists? lol maybe this has become to technical for DoowNimajneb
big_smile


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#21 2012-06-30 07:12:47

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

Re: Gliding Randomly! HELP!

just wondering (because these posts are going a little off-topic) Is there any other way to get my coin to stop if it hits one of 17 sprites without using scripts? Or can someone give me a definate/straight answer to whether I can use lists or not?
Thanks,
DoowNimajneb

Offline

 

#22 2012-06-30 07:16:07

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

Re: Gliding Randomly! HELP!

I meant to say "instead of using lists" sorry!

Offline

 

#23 2012-06-30 07:50:21

daniel_j
Scratcher
Registered: 2012-05-22
Posts: 100+

Re: Gliding Randomly! HELP!

Here is a script for your gliding coin:

when I receive [broadcasted thing v]
repeat until <touching [board v]?>
glide (1) secs to x: (Pick random (1) to (360)) y: (pick random (1) to (360))
end
hide
Here is a script to stop once it touches a coin:
when I receive [broadcasted thing v]
forever
if <touching [sprite v]?>
hide
smile

Last edited by daniel_j (2012-06-30 08:00:46)


http://i50.tinypic.com/2dhgnsx.jpg

Offline

 

#24 2012-06-30 08:11:47

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

Re: Gliding Randomly! HELP!

I'm sorry, if you want to detect colision with multiple sprites at once, you have to do

repeat until <<touching [a sprite v]?> or <<touching [another sprite v]?> or <<touching [a third sprite v]?> or <<touching [yet another sprite v]?> or <<touching [one more sprite v]?> or <...>>>>>>
stuff
If all the sprites you want to detect are the same colour, and nothing else is that colour, you can use
 <touching color [#65de7a]?> 
block, but if not, you'll have to use the long one above. Perhaps a future version of scratch might have a way to group sprites together then have a
 <touching sprite from group [ a group v]?> 
block, but the current version doesn't, so you'll have to use the above method.

Last edited by joefarebrother (2012-06-30 08:12:22)


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

 

#25 2012-06-30 13:24:23

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Gliding Randomly! HELP!

amcerbu wrote:

^^Not really...

Let's say there are 100 objects on the screen, meaning 100 items in the list to check.  The main object will move, and every frame, will check if it is touching a random 1 of these 100.  That means that if it is actually touching a specific object, there is only a 1/100 (1%) chance that it will register collision with that object.

I don't think that this project will be using 100 sprites (maybe 15 is a reasonable guess) but that's still only about a 7% accuracy rate.

He said 17, so it does give a fairly usable result.

Because he's not doing any long script in the event, he's merely stopping movement.


Hai.

Offline

 

Board footer