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.

Newcomers DBPro Corner / How to create lightning effect (particle effect) with Darkbasic Pro

Author
Message
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 27th Jul 2011 03:19
Hello my friends.

I am looking some way to make some lightning effect (like static electricity or thunder) effect with DarkBasic , is it possible to be happen with some code or library or dll , or even with some program which generates lighning effect?

I am creating special portals for my game and when my portals opens , lighning effects will uppear on the wall. (On the corners of the portal) and then the vortex will open.

Attachments

Login to view attachments
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 27th Jul 2011 03:32 Edited at: 27th Jul 2011 03:33
I have and one sample picture how the portal will be...

In the post above , I have one demo , about what I have created so far.

Attachments

Login to view attachments
Kezzla
16
Years of Service
User Offline
Joined: 21st Aug 2008
Location: Where beer does flow and men chunder
Posted: 27th Jul 2011 06:58
Hi
I'm also trying to figure out lighting for a 3d game. IT's a hard one and I still haven't nailed it.

for your 2d project maybe look into sprites, that or a lightning image with transparent background on a plane that is flashed up on the screen.

If you want more random 2d lightning try using random increasing variables on the y axis and fluctuating variables for the x axis and draw some lines with the values(will give you a random zigzaggy line, sorta looks lighningy) with a bit of tweaking that could look good, but I havnt nailed it yet.

i'm about to start working on a 3d lightning subroutine that generates the strike in 3d space, still in mental planning stage of the project, but I think it will be best for 3d lightning.

hope you got some ideas out of this.

kezzla

Sometimes I like to use words out of contents
Butter fingers
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 27th Jul 2011 19:22
Ok, this is how I do lightning, but my function requires you to have certain objects. so I'm doing this in pseudo code, so I hope it makes sense.

make a object. call it "dummy".

get the distance between the start and end of where you want the the lightning (cloud to ground/gun to target\whatever). call this "dist"

divide dist by 7

a=dist*2
b=dist*3
c=dist*4
d=dist*5
e=dist*6

position dummy at start point.

point dummy at end point

(using "move object" command)move dummy "a"

move dummy a small random amount, left/right and up/down

store the XYZ co-ords of dummy.

reposition dummy at start

point dummy at end point

(using "move object" command)move dummy "b"

move dummy a small random amount, left/right and up/down

store the XYZ co-ords of dummy.

repeat this process for all your variables up to "e"

now use something like D3Dline function in Matrix1 DLLs to draw a line between:

Start and a
a and b
b and c
c and d
d and e
e and end point

you now have lightning.

Sleep is over-rated.
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 27th Jul 2011 21:17
Is this for 3D or 2D?
Why do I make an object?
Instead of object if I create a pixel?
I don't understand your idea.

Is This a code for 3D Lightning?
In fact might the idea is closer to Kezzla , about zigzag lines.
But I don't have the particle algorithm yet in my mind.

Or I will draw some 2D sprites.
Or some manual pixel drawing.
Butter fingers
18
Years of Service
User Offline
Joined: 20th Mar 2006
Location: Mecca
Posted: 28th Jul 2011 12:03
Quote: "Is this for 3D or 2D?"


It's for 3D

Quote: "Why do I make an object?"


To track the positions you need more easily

Quote: "Instead of object if I create a pixel?"


Won't work for 3D

Quote: "I don't understand your idea."


I can try and re-explain, but only if you tell me which bit you don't understand

Quote: "Is This a code for 3D Lightning?"


Yes (again)

Quote: "In fact might the idea is closer to Kezzla , about zigzag lines.
But I don't have the particle algorithm yet in my mind."


This gives you zig zag lines in 3D.

Quote: "Or I will draw some 2D sprites.
Or some manual pixel drawing. "


OK.

Sleep is over-rated.
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 29th Jul 2011 18:29 Edited at: 29th Jul 2011 18:30
If I will create a 2D plane as an object in size 1x1x1 like a pixel , but , I thing 3D object appears only in cameras? , I don't have a camera at all in my game , my engine is not 3D , the 3D walls are 2D images.
And in 3D space there are X , Y and Z values. How do I know in which 3D x,y,z value are the coordinates of my objects? There are x and y positions on my screen in my game.

I had another idea to create some routine which uses the line command and creates the zig zag lines and moves the vertices of the line randomly and giving the effect of the lightning shock effect.

But will not good in the eye.

I have one image with the idea.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Jul 2011 18:57
Takis,

Butterfingers just explained your idea with pseudo code, and how to implement it to better effect.

Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 30th Jul 2011 02:51
Ok I will try to write a code for this , but what are a,b,c,d and e?
Dummy objects like:

Dummy_a
Dummy_b
Dummy_c
Dummy_d
Dummy_e


I started like this:




Is correct so far?

Then in my gameloop I will have another gosub label:




I will call the initialization code first when the game starts.

And in the game loop I will update constantly the lightning effect.

This is my preparation code.

I have one little problem , I don't know the 3D commands of DarkBasic yet , I don't have tried to create any 3D game yet , I mean real 3D.

But am I in correct road?

Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 30th Jul 2011 05:17
Here's something I was just playing around with.

Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 31st Jul 2011 00:38
Yes your idea is very close.
I need to study how to make more lightning effects.

Also I will try to make and 2D sprites.

Thank you very very much for your help.

Login to post a reply

Server time is: 2024-11-24 03:04:57
Your offset time is: 2024-11-24 03:04:57