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.

DarkBASIC Professional Discussion / Get Object Screen X and Y, and Fading a Sprite

Author
Message
L3mmy
17
Years of Service
User Offline
Joined: 19th Jun 2009
Location: England, Sheffield
Posted: 19th Jul 2012 22:42
As the title says, I have a sun as an object (4 I think) and I basically want to fade a white sprite in as you look closer to the sun, But I also need to figure out how to prevent it through other onjects like buildings...

Tom

www.monsterwareltd.co.uk <--Visit today

Software, Games, Themes, Hosting, Wallpapers and more to come!
Aaron Miller
20
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 23rd Jul 2012 08:24 Edited at: 23rd Jul 2012 08:25
You're asking how to determine if an object is occluded. Here's a simple method:

(1) Take the sun's screen x and y
(2) Use 'pick object' with those coordinates
(3) Check if the object is the sun (or sky box, or whatever you're using to display your sun).
(4) If it is, proceed to step 6
(5) It's not: hide your "flare" object; do not proceed with the following steps.
(6) Show your "flare" object.
(7) Apply your fade operation.

I can't tell what you're looking for (in terms of "fade") here, exactly. It's hard to tell without context. Are you trying to do lens flare?

Cheers,
Aaron

EDIT: PS: I make no claims of efficiency for my method, btw. There are things you can do, like only checking every 'x' frames. Checking if the object is even in view before doing any of these operations. etc.

L3mmy
17
Years of Service
User Offline
Joined: 19th Jun 2009
Location: England, Sheffield
Posted: 23rd Jul 2012 11:08
Well I kind of have the lens flares working, I just want to make a blinding effect when you look closer to the sun..so as the sun gets closer to the center of the screen, start to fade in the white sprite until it's dead in the center and almost fully faded in

www.monsterwareltd.co.uk <--Visit today

Software, Games, Themes, Hosting, Wallpapers and more to come!
Max P
16
Years of Service
User Offline
Joined: 23rd Jan 2010
Location:
Posted: 23rd Jul 2012 11:36
You can do a simple distance check:

I didn't test the code, but it should work

Login to post a reply

Server time is: 2026-07-07 12:28:06
Your offset time is: 2026-07-07 12:28:06