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

#1 2008-12-21 08:56:28

Natheyecea
Scratcher
Registered: 2008-12-20
Posts: 4

Make a sprite avoid and run away from another sprite

http://scratch.mit.edu/projects/Natheyecea/357266

Okay, this game is pretty nice now, but I have another little thing I´d like to add to it. Sorry for asking so much, but this is my first game I have made with scratch, and I´m still learning  tongue

I have already added sprite2 wich is the other black thin thing. You can also move it around freely, and put it in the blue little pasture in the lower left so it won´t run around and interrupt anything when you don´t use it.

What I want is that when sprite1 is coming near sprite2, sprite2 should run away. If sprite1 are coming near sprite2´s backside, sprite2 will run forward. If sprite1 comes near sprite2´s side, it will turn around and run away from sprite1. If sprite1 are coming near the front (head) of sprite2, it should turn around 90*

Offline

 

#2 2008-12-21 12:40:09

shadow_7283
Scratcher
Registered: 2007-11-07
Posts: 1000+

Re: Make a sprite avoid and run away from another sprite

Natheyecea wrote:

http://scratch.mit.edu/projects/Natheyecea/357266

What I want is that when sprite1 is coming near sprite2, sprite2 should run away. If sprite1 are coming near sprite2´s backside, sprite2 will run forward. If sprite1 comes near sprite2´s side, it will turn around and run away from sprite1. If sprite1 are coming near the front (head) of sprite2, it should turn around 90*

I don't think this script meets your specific requirements but give it a try anyways.

(Sprite 2)
<when green flag clicked>
<forever>
<if><< <( distance to sprite 1 <<> 80 )>
<if><( distance to sprite 1 <>> 0 )>
<point in direction( (( direction of sprite 1 <-> 180 ))
<move(10 )steps>

Last edited by shadow_7283 (2008-12-21 12:41:42)

Offline

 

Board footer