Pages: 1
Topic closed
Help would be much appreciated.
Offline
Just get a list of distances and pick the smallest value.
Don't try it with more than about 20 sprites or it will probably lag too much.
Offline
[blocks]
<when green flag clicked>
[add <distance to[ sprite2 ]> to [List] ]
[add <distance to[ sprite3 ]> to [List] ]
-So on so forth-
<set{ Line }to( 2 )>
<set{ Lowest }to( ( Item 1 of [ List ] ) )>
<repeat( Length of [ List ] )>
<if><( (Item (Line) of [List] <<> <{ Lowest }> )>
<set{ Lowest }to( ( Item (Line) of [ List ] ) )>
<end>
<change{ Line }by( 1 )>
<end>
<say[ <{ Lowest }> ]>
[/blocks]
Does that help?
I'll create a project.
Project: http://scratch.mit.edu/projects/Magnie/718306
Last edited by Magnie (2009-10-15 16:05:55)
Offline
No problem, but I reliazed it's not exactly what you want, you'll need to add stuff on the bottom for the main sprite to point towards the closest sprite.
Offline
archmage wrote:
Just get a list of distances and pick the smallest value.
Don't try it with more than about 20 sprites or it will probably lag too much.
I'm not really sure how to do that. Btw thanks for the tip. Could you show me how to do that please?
Offline
Magie wrote the exact script you need to use
Offline
Topic closed
Pages: 1