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

#1 2011-09-21 10:23:30

fcomputer
New Scratcher
Registered: 2011-09-21
Posts: 3

Avoid being colided ?

Im so confused 'bout my aquarium project .
I have a diver and some fish,
here is the problem, when the diver move closer to the fish, the fish move to avoid the diver. how to do that ?
help me please  sad

Offline

 

#2 2011-09-21 11:06:31

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: Avoid being colided ?

fcomputer wrote:

Im so confused 'bout my aquarium project .
I have a diver and some fish,
here is the problem, when the diver move closer to the fish, the fish move to avoid the diver. how to do that ?
help me please  sad

should the fish forever avoid the diver or should they allow the diver to catch up to them?


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#3 2011-09-21 11:42:31

fcomputer
New Scratcher
Registered: 2011-09-21
Posts: 3

Re: Avoid being colided ?

4lover wrote:

fcomputer wrote:

Im so confused 'bout my aquarium project .
I have a diver and some fish,
here is the problem, when the diver move closer to the fish, the fish move to avoid the diver. how to do that ?
help me please  sad

should the fish forever avoid the diver or should they allow the diver to catch up to them?

yes. forever avoid the diver...

Offline

 

#4 2011-09-21 11:58:27

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Avoid being colided ?

You'll have to make the fish move it the opposite direction of its relation with the diver. In Scratch blocks, you could try this:

[blocks]
<forever>
<point towards( diver
<turn cw( 180 )degrees>
<move( 5 )steps>
<end>
[/blocks]

Last edited by LS97 (2011-09-21 12:01:17)

Offline

 

#5 2011-09-21 12:12:00

fcomputer
New Scratcher
Registered: 2011-09-21
Posts: 3

Re: Avoid being colided ?

LS97 wrote:

You'll have to make the fish move it the opposite direction of its relation with the diver. In Scratch blocks, you could try this:

[blocks]
<forever>
<point towards( diver
<turn cw( 180 )degrees>
<move( 5 )steps>
<end>
[/blocks]

Thanks ,  but itsn't work well ..
the fish move into the edge and get error  sad

Offline

 

#6 2011-09-21 12:17:03

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: Avoid being colided ?

Well I think I have a good solution except for a couple questions do you want the fish to be covering the entire screen or just a straigh line and what are the controls for the diver


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#7 2011-09-21 12:37:07

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Avoid being colided ?

OK, I got a better version. How about,
http://dl.dropbox.com/u/11532575/forums/distanceMove.gif

Offline

 

#8 2011-09-21 19:02:14

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Avoid being colided ?

LS97 wrote:

OK, I got a better version. How about,
http://dl.dropbox.com/u/11532575/forums … ceMove.gif

It might be a good idea to detect the distance to the edge, then have the sprite begin turning away from the wall when it gets too close so it doesn't collide with it.

Also moved to All About Scratch, the forum for Scratch programming questions.  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer