Question about whatdotcolor
Author |
Message |
DemonZ
|
Posted: Tue Oct 31, 2006 10:47 pm Post subject: Question about whatdotcolor |
|
|
Ok heres something im wondering about with whatdotcolor, can u use whatdotcolor for collision detection when dealing with imported pictures? Because theres a chance that whatdotcolor will not recognize the color of the pic and therefore not calculate the collision at all, or would u have to use drawfillbox under the pic and calculate it that way? I have tried experiments with this and havent turned up succesful, if someone can tell or show me a way of using whatdotcolor with pics it would be a big help. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Wed Nov 01, 2006 2:24 am Post subject: (No subject) |
|
|
You could use it for collision the same way as you whould with drawn shapes in turing. The reason that it is probly not working for you some times is that your image is not the right color in parts. Red in turing might not be the same red in MS paint or other editors (ie. red might not be 255, 0, 0 and could be an off shade like 255, 1, 1).
Athougth it should work, i whould not recomend using whatdotcolor for collision dection on complicated projects or programs that you whont to be resuseable or added to. There are other methods of collision dection that will not be messed up by a color change or general change in your pic files or what you are drawing on the screen. You can find information on thess methods in the turotrals section of the site. For more help with whatdotcolor post some of the code you are having problems with and hopfully some one will be able to find the problem. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
TokenHerbz
|
Posted: Wed Nov 01, 2006 4:36 am Post subject: (No subject) |
|
|
you couldn't draw a box underneath your picture either, because whatdotcolor looks at the colors which is "on top" or so i believe.
if you draw a small circle red, and a bigger box black over it, whatdotcolor shouln't beable to see red at all.
A method i use for pictures which can change but are the same size (like different positions of an RPG hero), is the x,y to how big the unit is.
Use this in a collition fcn, experiment, i dont want to give you code, but suggest an alternative answer then using whatdotcolor. |
|
|
|
|
|
Clayton
|
Posted: Wed Nov 01, 2006 9:11 am Post subject: (No subject) |
|
|
If you absolutely wanted to use whatdotcolor in your program, there is a way of doing it. The only problem with it is that it is very slow as you are drawing twice as many pictures *shudders*. What you do is open up paint and open up the picture you want to use. Draw some sort of solid color over where you want the collision to happen. Save it under a different name. When you run the program, draw the colored picture first, do you collision check, then draw the original over the colored one.
As stated above, this method is extremely slow and should be avoided. You are better off using some sort of math, or just fudging it and make your picture a square and do collision detection like that. |
|
|
|
|
|
Dan
|
Posted: Wed Nov 01, 2006 12:18 pm Post subject: (No subject) |
|
|
Some clearifcation:
whatdotcolor only returns the color of the pixel of the vissibel drawing area. There is no way to make whatdotcolor see under a pixel becues there is nothing under it. What you can do with pics is make parts of them transparnt and both you can whatdotcolor can see threw the transparnt parts.
I honstly am unshure of the time diffrences between using whatdotcolor and other colesion dection methods. If i had to guses i whould say whatdotcolor could aucatly be faster in some cases where the quality of dection dose not matter that much. However if you whont to do exteramly good quality dection (ie. not just testing a pixel infront of it or a box around it) then other methods will be much faster.
The main problem with whatdotcolor consion dection is not speed but it is almost bad progaming becues it makes it very hard to update the program at a latter time. For example if you whont to change all the pictures in your program then you will have to change all the color values you are checking. Also whatdotcolor dection ushely only works well in simple looking cases where every object is only one color. (ie. the floor is green and the walls are red). In more advaced looking games the walls could be any color or shades of color witch whould make whatdotcolor useless.
Also whatdotcolor dection ushely only checks one pixel infront of the object. This method again works in cases where the objects are simple like in a pong game but once you get complicated objects you need to check more places, thous whatdotcolor whould get complicated alot faster and be harder to code.
If you give more infomration about what you are trying to do we could sugested a better method or how to use whatdotcolor better. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Clayton
|
Posted: Wed Nov 01, 2006 1:52 pm Post subject: (No subject) |
|
|
Yes, but if you DO want/need to use whatdotcolor, then use my method, draw the solid colored picture, do the collision detection, then draw the actual picture, this way, you can check for a color "underneath" a picture, its best if you use the View.Set("offscreenonly") View.Update combo here, so you don't see a random solid picture in the background. |
|
|
|
|
|
ZeroPaladn
|
Posted: Wed Nov 01, 2006 2:28 pm Post subject: (No subject) |
|
|
I agree with Freakman, if you have to use whatdotcolour.
Turing: | View.Set ("offscreenonly")
loop
% draw solid colour "layer" using the sprites co-ordinates
% whatdotcolour collision detection
% draw actual sprite/background
View.Update
end loop |
|
|
|
|
|
|
Andy
|
Posted: Wed Nov 01, 2006 7:37 pm Post subject: (No subject) |
|
|
YOUR method eh? i think someone needs to read the watdotcolor tutorial.
I already discussed a better way of whatdotcolor collision detection in here |
|
|
|
|
|
Sponsor Sponsor
|
|
|
neufelni
|
Posted: Wed Nov 01, 2006 8:31 pm Post subject: (No subject) |
|
|
I had to do this for a program that I made once. What I did was just load the picture in a separate Turing program, and print the whatdotcolor at whatever pixel I needed to know the color of. Like this:
code: | Pic.ScreenLoad("pic.bmp", 0, 0, picCopy)
put whatdotcolor(10, 10) |
|
|
|
|
|
|
DemonZ
|
Posted: Wed Nov 01, 2006 8:47 pm Post subject: (No subject) |
|
|
Im asking mainly about whatdotcolor because Im trying to have collision detection with two rectangular pics (ex. a tank and a tank bullet) but these pictures rotate when u use the controls, so im thinking if i should use rectangular collision or circular collision, Im not so sure that the circle method would be good because it would make the collision fairly unaccurate and rectangular would be completely useless as when the values between x1 and x2 can change, meaning that x2 is bigger value then x1 but when rotated to a certain degree and x1 becomes a larger vaule than x2, any suggestion would be great on how to solve this problem, if u want i can post my program here and show u exactly what Im having problems with. |
|
|
|
|
|
TokenHerbz
|
Posted: Thu Nov 02, 2006 12:41 am Post subject: (No subject) |
|
|
with math, all collitions are accurate...
Good math, anyways. |
|
|
|
|
|
Andy
|
Posted: Thu Nov 02, 2006 1:37 pm Post subject: (No subject) |
|
|
really.. show me how to do irregular convex polygons collision detection with math |
|
|
|
|
|
|
|