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

#1 2010-01-11 16:42:04

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Color-Based Sensing - Good or Bad?

Color-based sensing, is when a sprite senses a wall or object or something, bu using the <if color [] is touching color []> or <if touching color []> blocks. Its the most basic method of sensing, as it is simple to do. For those who don't know about any other methods of sensing, or want to know more about them, here's some quick descriptions.

Sprite-based sensing, is when there is 4 or more alternate sprites other than the main character which sense each side of the character, using a variable, such as leftHitTest, rightHitTest, downHitTest, and upHitTest. Each sprite always goes to the position of the main character, and if it is touching another object or color then it sets it's variable to 1, or else 0, like a boolean. And of course these sensors are with 100% Ghost Effect on. The player uses these variables to help it's movement.

Array-based sensing, is the most uncommon, and is where there is a list of positions of where every block on the level is, and the character uses that list, with it's x and y position to determine if it is touching the wall. This is what I use for my One-Sprite One-Script Level Creator Player, my Mario Level Creator Player, and my Lego Level Creator Player.

Now let's compare then, with some pros and cons.

Color-Based Sensing
+Simple and easy to implement
-Inaccurate
-Looks weird when a sprite isn't supposed to have those colors on it.

Sprite-Based Sensing
+More accurate than Color-Based Sensing
+Still somewhat to implement.
-Slightly more laggy.
-When you press the stop button, the ghost effect goes away so you can see the sensors.

Array-Based Sensing
+Very accurate
+Just as, maybe a bit less laggy than sprite-based sensing
+Can create level creators and level codes with  lol
-Difficult to implement
-Only works in some situations.

So I want to hear your opinions. Do you think Color-Based Sensing is all that great? Whats your opinion on the other sensing methods?

Discuss.  smile

In my opinion, color-based sensing is bad to use, and is just a don't. For your first couple of games, sure, but at least grow into the sprite-based sensing. For most games, I recommend just sprite-based sensing. In other situations though, you can use Array-Based Sensing, but rarely, so for the most part, skip that.


http://i.imgur.com/WBkM2QQ.png

Offline

 

#2 2010-01-11 16:47:47

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Colour based sensing is MUCH faster than normal sensing, becuse it doesn't have to detect for pixel perfect collision for all the sprites to be collided with.

The "If Touching" Block lags. A lot. With pixel perfect sensing comes a hefty price, speed. You may have noticed that games that use a lot of hit-tests (archmage games) run slowly outside presentation mode because of this.

Array based sensing is very impractical in scratch. Why? Because of lack of support for multi-dimentional arrays. People have to emulate multidimensional arrays, which also comes at a price.

Offline

 

#3 2010-01-11 16:50:49

Jonathanpb
Scratcher
Registered: 2008-07-25
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

I just use whatever is best in the situation.  wink


"Human beings... must have action; and they will make it if they cannot find it.
-Charlotte Brontë

Offline

 

#4 2010-01-11 16:52:36

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

There is a method where you have a sprite with a costume without the color sensing, and a costume that has the color sensing over it.  Start it with the costume on color sensing, implement the sense scripts, and switch it back to the normal costume.

It's fast, its easy, and it doesn't have those weird colors over it.

Problem solved  big_smile

Last edited by Kileymeister (2010-01-11 16:54:22)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#5 2010-01-11 16:55:24

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Kileymeister wrote:

There is a method where you have a sprite with a costume without the color sensing, and a costume that has the color sensing over it.  Start it with the costume on color sensing, implement the sense scripts, and switch it back to the normal costume.

It's fast, its easy, and it doesn't have those weird colors over it.

Problem solved  big_smile

Aha - but everything that happens in scratch has a cost. Switching costumes is one of them.

Offline

 

#6 2010-01-11 16:57:37

pinochio
Scratcher
Registered: 2009-03-19
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

It is innacurate sometimes, but its pretty useful.


Flat Out G

Offline

 

#7 2010-01-11 17:02:34

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

And also I hate how everyone uses Hit-tests. You DO NOT ever need them.

Just move x-velocity, check for X-collisions then move Y-velocity, check for Y collisions. You can get whether it's up/down from the starting veloicity.

Last edited by RHY3756547 (2010-01-11 17:02:58)

Offline

 

#8 2010-01-11 17:05:10

ScratchX
Scratcher
Registered: 2009-05-05
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

And also I hate how everyone uses Hit-tests. You DO NOT ever need them.

Just move x-velocity, check for X-collisions then move Y-velocity, check for Y collisions. You can get whether it's up/down from the starting veloicity.

I noticed that when i was programming NinjaX


Happy New Year!
http://i45.tinypic.com/1nyasi.pnghttp://i50.tinypic.com/219pez8.pnghttp://i49.tinypic.com/e5s4zr.pnghttp://i48.tinypic.com/23l18hf.jpghttp://i49.tinypic.com/66zymu.png

Offline

 

#9 2010-01-11 17:07:06

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

Kileymeister wrote:

There is a method where you have a sprite with a costume without the color sensing, and a costume that has the color sensing over it.  Start it with the costume on color sensing, implement the sense scripts, and switch it back to the normal costume.

It's fast, its easy, and it doesn't have those weird colors over it.

Problem solved  big_smile

Aha - but everything that happens in scratch has a cost. Switching costumes is one of them.

Yeah, but its instantaneous.  No one notices. At least with my method its instantaneous.  How is switching costumes a cost?


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#10 2010-01-11 17:07:57

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Kileymeister wrote:

RHY3756547 wrote:

Kileymeister wrote:

There is a method where you have a sprite with a costume without the color sensing, and a costume that has the color sensing over it.  Start it with the costume on color sensing, implement the sense scripts, and switch it back to the normal costume.

It's fast, its easy, and it doesn't have those weird colors over it.

Problem solved  big_smile

Aha - but everything that happens in scratch has a cost. Switching costumes is one of them.

Yeah, but its instantaneous.  No one notices. At least with my method its instantaneous.  How is switching costumes a cost?

The scratch engine has to interpret mode code AND it has to rerender the scene. With enough, the game will become jittery.

Last edited by RHY3756547 (2010-01-11 17:08:16)

Offline

 

#11 2010-01-11 17:08:49

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

Kileymeister wrote:

RHY3756547 wrote:


Aha - but everything that happens in scratch has a cost. Switching costumes is one of them.

Yeah, but its instantaneous.  No one notices. At least with my method its instantaneous.  How is switching costumes a cost?

The scratch engine has to interpret mode code AND it has to rerender the scene. With enough, the game will become jittery.

Yeah but no one cares.  It runs fine with switching costumes.  tongue


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#12 2010-01-11 17:12:40

Lucario621
Community Moderator
Registered: 2007-10-03
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

Colour based sensing is MUCH faster than normal sensing, becuse it doesn't have to detect for pixel perfect collision for all the sprites to be collided with.

The "If Touching" Block lags. A lot. With pixel perfect sensing comes a hefty price, speed. You may have noticed that games that use a lot of hit-tests (archmage games) run slowly outside presentation mode because of this.

Array based sensing is very impractical in scratch. Why? Because of lack of support for multi-dimentional arrays. People have to emulate multidimensional arrays, which also comes at a price.

You know too much. Shoo shoo away!  lol  j/k

But lolz is this basically common knowledge for every programming language? Because you sure know a lot lolz >.>

Based on what I've read so far, your new motto is "which comes at a price". Seriously it feels like you've said that 3 times.

Last edited by Lucario621 (2010-01-11 17:13:03)


http://i.imgur.com/WBkM2QQ.png

Offline

 

#13 2010-01-11 17:13:20

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Kileymeister wrote:

RHY3756547 wrote:

Kileymeister wrote:


Yeah, but its instantaneous.  No one notices. At least with my method its instantaneous.  How is switching costumes a cost?

The scratch engine has to interpret mode code AND it has to rerender the scene. With enough, the game will become jittery.

Yeah but no one cares.  It runs fine with switching costumes.  tongue

I care.  sad

Every fps lost from scratch's low max fps of 40 makes me cry. :'(

Offline

 

#14 2010-01-11 17:14:14

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Colour sensing is good if the colour doesn't look out of place. If you have purple lines everywhere then it looks unprofessional.

Sprite based sensing is good for testing collisions at specific points but it does lag a bit.

Array sensing is good for many programming languages, but not scratch. There is no reason I can think of to use array based sensing in large scrolling levels. Its hard to code and laggy.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#15 2010-01-11 17:14:59

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

Kileymeister wrote:

RHY3756547 wrote:


The scratch engine has to interpret mode code AND it has to rerender the scene. With enough, the game will become jittery.

Yeah but no one cares.  It runs fine with switching costumes.  tongue

I care.  sad

Every fps lost from scratch's low max fps of 40 makes me cry. :'(

The max is only 40???

So THAT's why my huge game Disaster can only run at 17 fps...


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#16 2010-01-11 17:32:58

floatingmagictree
Scratcher
Registered: 2008-10-21
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

I've used color collision in Sphered, PapiJump, and iCopter. I find it more useful, as I want to try and eliminate lag in my games.

Offline

 

#17 2010-01-11 17:41:49

RHY3756547
Scratcher
Registered: 2009-08-15
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Kileymeister wrote:

RHY3756547 wrote:

Kileymeister wrote:


Yeah but no one cares.  It runs fine with switching costumes.  tongue

I care.  sad

Every fps lost from scratch's low max fps of 40 makes me cry. :'(

The max is only 40???

So THAT's why my huge game Disaster can only run at 17 fps...

Actually - that's the interpreter not being able to keep up with the lowly framerate of about 40.

The scratch team have plenned to meke every part of scratch online (including the editor) by v2.0, which will mean it will all be Java, so why not make scratch compile applications into java? It would lose the lag of the interpreter (basically ALL of the lag) and would allow for more graphically intense games with the CPU processing use lower.

Offline

 

#18 2010-01-11 17:58:13

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

RHY3756547 wrote:

And also I hate how everyone uses Hit-tests. You DO NOT ever need them.

Just move x-velocity, check for X-collisions then move Y-velocity, check for Y collisions. You can get whether it's up/down from the starting veloicity.

I think that it may be my fault that people use those, since a lot of people learn how to do that from my projects. The reason I do collisions like that is because that is how I learned how to make collisions for platformers in actionscript. In actionscript there is a command called a shapeflag hit test that lets you check for collisions at specific coordinates. Since scratch doesn't have a shape flag hit test or something similar I used sprites.

Sorry for promoting sloppy code, maybe you can code a platformer engine that doesn't use sprites for collisions and I can refer people to that one instead.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#19 2010-01-11 18:03:51

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

Lucario621 wrote:

But lolz is this basically common knowledge for every programming language? Because you sure know a lot lolz >.>.

No, this isn't common knowledge for programmers. You only start to become concerned with things like collision testing when you start to make games which is something a lot of programmers (at least the ones I know) don't get too much into.

Scratch is shallow enough to understand everything pretty quickly if you already know programming.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#20 2010-01-11 19:22:52

cocoanut
Scratcher
Registered: 2007-07-10
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

floatingmagictree wrote:

I've used color collision in Sphered, PapiJump, and iCopter. I find it more useful, as I want to try and eliminate lag in my games.

Except I didn't like Sphered because you didn't change the costume from color-sensing to regular and back or make it roll. >.> I liked fg123's method.


http://i42.tinypic.com/20gyvif.jpgPlease leave a message at the beep.
Steam: Hellephant

Offline

 

#21 2010-01-11 22:35:41

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Color-Based Sensing - Good or Bad?

I like color based sensing, but when you use common colors, you have to make all the other sprites weird colors.


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#22 2010-01-12 14:33:11

everythingRhymes
Scratcher
Registered: 2009-12-03
Posts: 100+

Re: Color-Based Sensing - Good or Bad?

that's why you should use both color and sprite sensing. if there's like a fighting game, and you put 'if touching sprites', when you're attacking, and the opponent also happens to attack like 2 seconds later, you'll both be considered hit.

Offline

 

Board footer