Important alert: (current site time 7/16/2013 3:36:32 AM EDT)
 

winzip icon

Light Effects

Email
Submitted on: 7/18/2000 2:07:31 PM
By: Jotaf98 
Level: Intermediate
User Rating: By 25 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0, VB Script, ASP (Active Server Pages)
Views: 24541
(About the author)
 
     "DrawLight" is a function that I wrote because I wanted to add lightning effects to my game, if it was possible. Guess what, it is -- and here's the proof! Just have a look at that screenshot; it was made with my program, I didn't edit it with any other graphics program! :) It draws a light in any picture, but it's faster than most ways to achive this (because I used the circle's core equation instead of the Circle function). Also, you can choose the color that will be used in the effect, instead of a simple white light! As a "bonus", included is the code to draw a circle (its core equation), and something I did to remind people to vote me (because I noticed that 290 people had downloaded the Translucency effect, but only 2 had voted!) -- and automatically opens your browser and orders it to go to Planet Source-Code (it asks you if you want before doing it). And there's no need for backbuffers, as the light uses a very cool effect while loading ;) I'm working now on a way of doing this, but instead of a circle, you can use a mask! I also wanna make a variation of this for lasers (same way as the mask, but automatically draws the mask with a line).

 
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
  3. Scan the source code with Minnow's Project Scanner

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
7/18/2000 2:53:01 PMSean Gallardy

send me your game when u r done.
(If this comment was disrespectful, please report it.)

 
7/18/2000 6:34:15 PMNewmann

interesting... very original!
(If this comment was disrespectful, please report it.)

 
7/18/2000 7:10:02 PMJotaf98

Thanks!

Hum, it's gonna take a while until it's done... but when I finish it, I'll make a web site for it so people can download it. I'll post in www.vb-world.cnet forum when it's done.

Also, I'm doing a conversion to DirectX7 instead of the SetPixel/GetPixel APIs so it's faster and can be used in games.
(If this comment was disrespectful, please report it.)

 
7/19/2000 1:40:56 PMkerlin

nice effect! however, radius = 150 gives an overflow error...change long to int maybe? haven't looked at the code. will let you know what i find
(If this comment was disrespectful, please report it.)

 
7/22/2000 2:28:22 PMJotaf98

Ok, it's fixed now. Also, I'm uploading a new version right now... it lets you use a mask instead of a simple circle! It's called "Masked Light".
(If this comment was disrespectful, please report it.)

 
7/30/2000 4:43:44 AMSimon Price

Very original? See http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=9684 submitted a week earlier...
(If this comment was disrespectful, please report it.)

 
7/30/2000 7:12:57 PMJason

Hey Jotaf98! Thats really cool. I have one thing I'm modifing in that. I'm making it so the light appears where you clicked
(If this comment was disrespectful, please report it.)

 
8/5/2000 3:55:36 PMCool33

Simon is right, he made this, but better i might add, a week ago at http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?lngWId=1&txtCodeId=9684
(If this comment was disrespectful, please report it.)

 
8/11/2000 12:33:06 AMKillerQ13

Use these useful subs/functions to get RGB:

Function FixHex$(HexString As String, Length As Byte)
If Length > Len(HexString) Then
FixHex$ = String$(Length - Len(HexString), "0") & HexString
Else
FixHex$ = HexString
End If
End Function

Sub GetRGB(Number As Long)
Dim RGBColor As String

RGBColor = FixHex$(Hex$(Number), 6)
Red = CInt("&H" & Mid$(RGBColor, 5, 2))
Green = CInt("&H" & Mid$(RGBColor, 3, 2))
Blue = CInt("&H" & Mid$(RGBColor, 1, 2))
End Sub
(If this comment was disrespectful, please report it.)

 
8/16/2000 6:15:06 PMJotaf98

Thanks, KillerQ13!

Sorry for not replying before, I was on holydays for the past 3.5 weeks...

About TorchCursor... I admit your sample code inspired me to do this, but I only did it because I noticed that your way was very well done, but was using functions that are slow in VB (creating circles in a backbuffer and then getting the pixels there to check the ammount of light). I knew that there was an algorythm to figure out if a pixel is or not in a circle, and spent an entire night trying to find it and (when I found it in one of my father's books) studying it (it wasn't specially done for VB). I also used a different function for getting the rgbs, I added the support for colors and the part about using translucency to draw each pixel was taken from my other submission "Translucency".

Believe me, I did it from scratch, and I don't intend to have you as an enemy just because of this miss-understood.

Friends?
(If this comment was disrespectful, please report it.)

 
8/18/2000 6:28:28 PMJotaf98

Hum... I'm not sure if I must take that as a "no"...

I'll give ya some more time ;)
(If this comment was disrespectful, please report it.)

 
8/21/2000 1:28:33 PMSparq

whats everyones problem? Its not a competition. we are all here to learn about VB nd help others do the same.. (Good Code Jotaf98)
(If this comment was disrespectful, please report it.)

 
8/21/2000 6:36:36 PMJotaf98

Sparq is right. We're here to learn, not to see who has the best code.

Thanks, Sparq!
(If this comment was disrespectful, please report it.)

 
8/27/2000 10:54:17 PMAbdul

Jota you're a good guy. You're posting your nice code in order to help other people. Its not about the fame or the women, its about helping someone else out. :)
(If this comment was disrespectful, please report it.)

 
8/28/2000 4:40:09 PMJotaf98

You too, Abdul! You could simply use your "media player"'s code to win some money (by doing your own media player and selling it), but no, you distributed the source code so anyone could learn with it ;)
(If this comment was disrespectful, please report it.)

 
8/28/2000 4:42:08 PMJotaf98

And don't think I said that just because of what you said :p
(If this comment was disrespectful, please report it.)

 
12/16/2000 9:49:15 PMMitch

What exactly is the point of this? Not that it is bad or something, it is cool though.
(If this comment was disrespectful, please report it.)

 
12/19/2000 7:37:06 PMJotaf98

Don't worry, Mitch, I'm not offended or anything ;)

It's so you can use special effects in your games or in a painting program.

But you should look for "Special Effects for BitBlt games" I did a while ago, it's much faster!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.