Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / trying to get cross hair to change color when object is in the cross hair.

Author
Message
Lover of games
19
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 20th May 2008 06:44
Ok, i've tried to make it so that when the object is within the cross hair, the cross hair changes color, i'm not sure if you guys get what i'm saying. here is my code



of course, it doesn't work, what am i doing wrong? is there a better way? damn it i even did this a long time ago

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Mc Koding
16
Years of Service
User Offline
Joined: 13th May 2008
Location: Canada
Posted: 20th May 2008 08:12
There is a post like right under this that gets the x&y of an object if its on screen and then you can use that or i think there is a logic problem. Because width/height of screen divided by two is lets say a 100X100 = 50X50 so you get 50 out of it, now use the person jason or somthings code to see if its in bounds of the thing also a crosshair ( image wise) would be a diffrent color image or color the image using ( forgot function name).

( Yesh i am candanain , get it over eh!)

Rendetion a farcry from DarkGDK
Mc Koding
16
Years of Service
User Offline
Joined: 13th May 2008
Location: Canada
Posted: 20th May 2008 08:14
So i reviewed the code an see that it will only get it if the object is in the middle, so try making that with a nested loop and check if its in the range of lets say 16pixle

Rendetion a farcry from DarkGDK
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th May 2008 09:14
try this:
Lover of games
19
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 20th May 2008 15:19
thanks, jazzaa but that didn't work.

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th May 2008 18:51
ummm well are you redrawing the crosshair every frame? because with that command dbInk(dbRgb(255,0,0),0); you are not actually changing the crosshair colour, only the ink colour. This following code creates a black crosshair normally, that changes red when an object comes into veiw. i havnt tested it.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th May 2008 18:53
sorry, that will give you syntax errors. Change the first dbInk to
dbInk(dbRGB(255,0,0),0);
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 20th May 2008 18:55
idiot old me. change that to dbInk(dbRGB(0,0,0),0); and the code works fine for me. You might want to experiment with
if(dbObjectScreenX(total) < w+5 && dbObjectScreenX(total) > w-5 && dbObjectScreenY(total) > h-5 && dbObjectScreenY(total) < h+5)
and increase the 5s to 10s or soemthing.
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th May 2008 19:16
Slayer 706
16
Years of Service
User Offline
Joined: 18th May 2008
Location:
Posted: 21st May 2008 03:17
Quote: "ummm well are you redrawing the crosshair every frame? because with that command dbInk(dbRgb(255,0,0),0); you are not actually changing the crosshair colour, only the ink colour. This following code creates a black crosshair normally, that changes red when an object comes into veiw. i havnt tested it."
That code will turn the crosshair red even if the camera is not facing the object. I tried this and it seemed to work:
Thanks for the code by the way, it was a huge help to me.

Login to post a reply

Server time is: 2024-09-29 21:27:23
Your offset time is: 2024-09-29 21:27:23