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

#1 2012-04-25 11:11:07

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Sprite Sensing Terrains

I need to make a game with terrains made of different "materials" (e.g, metal boxes, wooden boxes, etc). I need to make my main sprite be able to sense when he is touching the terrains, so he will "know" to stop if there is an obstacle in front of him.

The main problem is that the materials are going to be made of different colors, so I can't use the color sensor. Some help?

Offline

 

#2 2012-04-25 11:15:30

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

Re: Sprite Sensing Terrains

Maybe you could add a 1px border around them of the same color?

Offline

 

#3 2012-04-25 13:17:19

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Re: Sprite Sensing Terrains

scimonster wrote:

Maybe you could add a 1px border around them of the same color?

No, I want it to look realistic. A green (or other color) line around everything will just make it look weird. (No offense intended.)

Offline

 

#4 2012-04-25 13:56:39

xJira
Scratcher
Registered: 2012-03-24
Posts: 91

Re: Sprite Sensing Terrains

If every block is an object, the diffrent blocks could sense, wether they are touching a sensor (they'll be made invisible) and then broadcast which one they're touching. But this would mean maaany objects.

Else, the 4 sensors (invisible of course ;D) check if they are touching one of the blocks colors. If grass has diffrent green-tones choose one for the sensor, this will probably work! But if the same color appears in another block, this could be a prob so you've got to be careful.

Offline

 

#5 2012-04-29 09:39:42

jedidiahzhu
Scratcher
Registered: 2011-01-16
Posts: 85

Re: Sprite Sensing Terrains

xJira wrote:

If every block is an object, the diffrent blocks could sense, wether they are touching a sensor (they'll be made invisible) and then broadcast which one they're touching. But this would mean maaany objects.

Else, the 4 sensors (invisible of course ;D) check if they are touching one of the blocks colors. If grass has diffrent green-tones choose one for the sensor, this will probably work! But if the same color appears in another block, this could be a prob so you've got to be careful.

I don't understand what you mean.  sad  It sounds very professional.  wink  Could you explain?

Offline

 

#6 2012-04-29 12:38:57

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

Re: Sprite Sensing Terrains

Rather than have one sensor colour you could just have the sensing sprite look for the colour that's on the outside of the terrains, and If they all react the same just use an and, else just have the individual scripts.


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

Offline

 

Board footer