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

#1 2011-01-14 11:21:50

gargh
New Scratcher
Registered: 2011-01-13
Posts: 4

keeping a sprite from touching another while going around it.

Okay, so. I cannot figure out how to make one of my sprites get from one side of the screen to the other without touching a few sprites I put in the middle. I have a red dot chasing a black dot, and I do not want the red dot to touch the box like sprites I put between the black dot and red dot. Any ideas? anybody? If what I'm not saying is clear, I will try and rephrase.

Offline

 

#2 2011-01-14 13:06:30

Sparta2
Scratcher
Registered: 2010-12-31
Posts: 11

Re: keeping a sprite from touching another while going around it.

It doesnt have to go straight you can make it go up and down to avoid the boxes


http://ui22.gamespot.com/1429/spartan_2.jpg http://www.davidbarrkirtley.com/images/300phalanx.jpg
lol  this is not Sparta people... or is it?

Offline

 

#3 2011-01-14 16:56:50

gargh
New Scratcher
Registered: 2011-01-13
Posts: 4

Re: keeping a sprite from touching another while going around it.

I suppose, but what I guess I'm trying to figure out is, say there is a 10 x 10 layout of squares, and the black dot is in the lower left hand corner and the red dot is in the upper right hand corner. Is there any possible way to make the red dot pick the fastest path through the 10 x 10 without it touching any of the squares?

Offline

 

#4 2011-01-14 17:26:20

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: keeping a sprite from touching another while going around it.

gargh wrote:

Okay, so. I cannot figure out how to make one of my sprites get from one side of the screen to the other without touching a few sprites I put in the middle. I have a red dot chasing a black dot, and I do not want the red dot to touch the box like sprites I put between the black dot and red dot. Any ideas? anybody? If what I'm not saying is clear, I will try and rephrase.

Try this:

Make a second sprite in front of the red dot that looks like a triangle with both sides a different color, like this:

http://img248.imageshack.us/img248/6185/screenshot20110115at110.png

Make sure the costume center is on the point of the triangle.

Now, give the sprite two variables like 'touching left' and 'touching right'. Add this script:

http://img818.imageshack.us/img818/1963/sensor.gif

Then, add this script to the red dot:

http://img13.imageshack.us/img13/2526/reddot.gif

Change the speed to your liking, and experiment with different heights and widths of the sensor and turning speeds, to see what works best.

Does this help?

Last edited by floppy_gunk (2011-01-14 17:37:48)


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#5 2011-01-14 19:37:46

gargh
New Scratcher
Registered: 2011-01-13
Posts: 4

Re: keeping a sprite from touching another while going around it.

Yes, it helps, but can it be made so that its more of a smooth rotation, instead of jerky? and my girlfriend says hi.

Offline

 

#6 2011-01-15 19:15:04

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: keeping a sprite from touching another while going around it.

I suppose you could have more sensors on the sides, and make the red dot only follow the black dot if the side sensors aren't sensing anything.  hmm  Although that might make way to more glitches.


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#7 2011-01-15 19:27:44

gargh
New Scratcher
Registered: 2011-01-13
Posts: 4

Re: keeping a sprite from touching another while going around it.

Okay, well, thank you, and my girlfriend says hi again.

Offline

 

Board footer