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 / Simple Flashlight Example (Doesn't use lights)

Author
Message
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 1st Dec 2009 23:27 Edited at: 2nd Dec 2009 01:59
Hi! I was bored when my unity update was downloading so I thought I would make a simple example on how to make a decent looking flashlight using only sprites (In essence it's just darkening the screen).

To use follow these steps to get the project to compile correctly (Should be ok if you use a Dark GDK Wizard):
1. Right click your project and select "Properties"
2. Click on the "C/C++" drop down and select "Code Generation".
3. Change Runtime Library to "Multi-Threaded (/MT)"
4. Click on the "Linker" drop down (below the "C/C++" drop down) and select "Input"
5. Add "atls, msvcrt" to the "Ignore Specific Library" box.
6. Then click on System in the "Linker" drop down list and change SubSystem to "Windows".

Then add this line of code before the main loop of your program:

The argument list:
1. The flashlight glow image to be used.
2. The image that will be representing the darkness or unlit places.
3 - 5. The sprites/images to be used.
6. How bright should the flashlight be?

That's it! Enjoy!

Here is screen shot of the flashlight in action:
http://www.freeimagehosting.net/image.php?f058a6b101.png

One problem that I just realized is that you can't use dbText to display text on the screen for the sprites overwrite it. If anyone can find a solution to this I would greatly appreciate it!

Your bedtime story is scaring everyone
If found my very own Fail!: http://cheezburger.com/View.aspx?aid=2712171776

Attachments

Login to view attachments
Outscape
16
Years of Service
User Offline
Joined: 23rd May 2008
Location:
Posted: 2nd Dec 2009 01:52 Edited at: 2nd Dec 2009 01:55
one word.

Wow.

that is pretty awesome!

[edit] looking at download now

[edit2] Nice little function you got there, thisll be very handy in my fps game
TYVM!



heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 2nd Dec 2009 01:57 Edited at: 2nd Dec 2009 01:57
Quote: "that is pretty awesome, so is FlashlightSetup a command? "

Thanks and yes it's the only command you need to make the flashlight work. But because this isn't really a flashlight just an illusion using sprites, the actual lighting is done using the default ambient lighting and the "flashlight" just darkens the screen and a pleasing way.

Your bedtime story is scaring everyone
If found my very own Fail!: http://cheezburger.com/View.aspx?aid=2712171776

Login to post a reply

Server time is: 2024-10-01 18:28:40
Your offset time is: 2024-10-01 18:28:40