Qbasicnews.com

Full Version: getting the color # value of one pixel on the screen
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
is there a way to find the number value
(1 is blue, 4 is red, 7 grey etc.) of a spot on the screen?
such as:
let color = col(100,250)
???????????????
i am using it for collision detection in a game and i would like to get the color value of the position that the projectile is at at one time
(if it passes over red it ingnites)
IS THERE A FUNCTION TO DO THIS?
i have already GOT (GET (blah,b...) the values of certain colors and printed the value on the screen, but they turn out to be something like 2.313824E-41 (happens to be color 1 -blue)
is there a way to get the normal colors values of a given position?

gaaaa! :barf: thx in advance folks
colorval = POINT(x,y)

Slow, but it'll work.
the reason that simply printing out the value of an array element didn't give you the right color value is because an array element is going to store at least 2 attributes ("color values"). However, since you got a floating point value printed out, I suspect you're likely using a SINGLE array to store your picture. In that case, your array element will be storing at least 4 attributes, or parts of them (depending on what video mode) you're using. You might want to use an INTEGER or LONG array, especially if you plan on doing any mathematical operations on your picture data. (SINGLE and DOUBLE data aren't stored all that accurately.)
well i DIMed the value to 4 values, but when i GEted the values i recorded that color to all four values and then printed just one

DIM a(4)
get yadda yadda (4pixels)
print a(1)

but i might have overlooked something.

i like the POINT idea but exactly how slow does it operate?
i need it to take less than 0.15 seconds on a 266 or so (so my game will run well on all computers)
but i will test it in the morning (its 10 and im tired lol)
but thanks ALOT for the help. lol that question was the reson i joined this forum lol
:lol:
THANKS AGAIN!
(unless somebody else has something that works the same or better , in that case, keep shooting away lol)
take less than .15 seconds on a computer even slower than a 266 Mhz machine. I'd be more concerned about your DIM statement, if I were you. Smile When you say

DIM a(4)

you're defining an array with 5 elements of 4 bytes each. That makes 20 bytes. Now, the first 4 bytes of that array, after you use GET to store the picture in it, are going to be occupied by numbers giving the width (or something related to it) and the height of the picture you stored. That leaves 16 bytes for the picture data itself. Is that enough space for your picture? (In mode 13, it would be enough, for example, for a 4 x 4 picture.) And if you want 4 bytes per element, I'd do

DIM a(4) AS LONG

(Without the "AS LONG" or some other type clause, or a DEFINT statement somewhere before the array, "AS SINGLE" is the default.)

And since I'll do just about anything to relieve mindboggling boredom, I just tested POINT out on a 66-Mhz 486. It took less than .000011 seconds (in the interpreter). And if that's not fast enough, in mode 13, the following might be faster, depending on how you use it (you really don't want to put it in a subroutine or DEF SEG everytime):

DEF SEG = &HA000
COLORVALUE = PEEK(320& * Y + X)


(The segment has to be set before using PEEK, but if your program requires a different segment in between PEEKs (for something else), you might lose some speed.)
Yep, peek would be your best choice or as an alternative:

C1=A(1) and 255
c2=A(1) \256
.
Actually no. I might try it out someday when the pentagon would commission me to make missiles. :*)
classifying this thread and taking you away to a secret lab?
Don't forget the straight-jacket.

;*)
Pages: 1 2