Check Colour Underneath
Author |
Message |
Hack.saw
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dan
|
Posted: Tue Jun 06, 2006 3:15 pm Post subject: (No subject) |
|
|
There is no function or comand to check what is under a draw image or shape becues there is nothing under them. whatdotcolor returnes the int reperstation of a given pixal. You give it the x and y value of the pixal you whont to know the color of and it returns the color.
To use it for colession dection you have to check the color of where the object will be not a pixal on the object becues obvesly it will allways be the same. |
Computer Science Canada
Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more! |
|
|
|
|
Hack.saw
|
Posted: Tue Jun 06, 2006 3:35 pm Post subject: (No subject) |
|
|
Ooooo.... so then you could use what.colour to check what the colour of where the object will be then use the required code (i.e x:=x-5 (is this right? ). I read the tutorial for what.colour but in are school we havent learned any of this yet and it got a little confusing and complictaed after the lil mini program that tells you " I know how to use what.colour" |
|
|
|
|
|
Guest
|
Posted: Tue Jun 06, 2006 3:45 pm Post subject: Check This Out |
|
|
Here is a colour pallet I made.
code: |
View.Set ("graphics:255;255,offscreenonly")
var key : array char of boolean
var x, y, button := 100
loop
Mouse.Where (x, y, button)
for i : 0 .. 255
drawfillbox (0 + i, 0, 255, 255, i)
end for
drawoval (x, y, 10, 10, black)
locate (1, 1)
put whatdotcolour (x, y)
Input.KeyDown (key)
if key (KEY_RIGHT_ARROW) then
x += 1
end if
if key (KEY_LEFT_ARROW) then
x -= 1
end if
if key (KEY_DOWN_ARROW) then
y -= 1
end if
if key (KEY_UP_ARROW) then
y += 1
end if
View.Update
end loop
|
|
|
|
|
|
|
Delos
|
Posted: Tue Jun 06, 2006 3:50 pm Post subject: (No subject) |
|
|
I believe you may be attempting to use wdc collision detection with complex shapes...the basic idea here is to create an invisible map of the screen with the necassary areas coloured in.
Complex object collision detection is inherently tricky. Wdc mapping is one of several approaches. Essentially, you'll draw the screen, update (using View.Update), then draw a 'map' of traversable areas over top. For the second part, you will not update, therefore it will remain invisible to the User. However, to the programme, only the map will be seen and hence collision detection can be implemented.
Go to [Turing Apps] and search for a Zelda game by Legolas. He submitted it quite a while back, but it incorporated this very idea. This programme will give you a good idea of what can be accomplished. |
|
|
|
|
|
Guest
|
Posted: Tue Jun 06, 2006 3:56 pm Post subject: Colour Pallet |
|
|
Hey, sorry to bum off this thread, but the program I made above, when you pass number 247, it see's 248-255 as colour 7. That's funny. I cant even differenciate 248-255. Also, in my code up there, you can trim it down to this, forgot to take it off:
Code:
View.Set ("graphics:255;255,offscreenonly")
var x, y, button := 100
loop
Mouse.Where (x, y, button)
for i : 0 .. 255
drawfillbox (0 + i, 0, 255, 255, i)
end for
drawoval (x, y, 10, 10, black)
locate (1, 1)
put whatdotcolour (x, y)
View.Update
end loop |
|
|
|
|
|
Delos
|
Posted: Tue Jun 06, 2006 4:02 pm Post subject: (No subject) |
|
|
Yup, Turing's idiosyncracies strike again! This all has to do with the way Turing creates colours.
All are made by sequentially altering the RGB values of the pixel in question. For the first 16 or so, these increments are quite large - much larger than those of the rest of the 240. That being said, it turns out that the increment used left over a couple of spaces at the end, so they were just filled with black. This black is indeed the same for each, so there is no difference between them. Being black, it is interpretted by wdc as 7.
As a bit of history, the reason the first ~16 colours differ from the rest is that in ol' DOS Turing, only 16 colours existed. Back then 0 was black and 7 was white. For various reasons, when Turing evolved to Windows, these colours were mostly kept intact. This means that for a student learning Turing, they needn't remember that colour #43 is blue and #75 is yellow (or whatever the numbers may actually be!) Personally, I don't like this and have often felt the need to recreate the palette to suite my own needs. (The RGB.() module can do this - though it doesn't affect wdc! Which defeats a lot of intents...) |
|
|
|
|
|
|
|