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.

Code Snippets / Thunder/Lightning Function

Author
Message
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 6th Jul 2006 18:26 Edited at: 7th Jul 2006 23:57
<EDIT>

Update: Previously the entire world would light up, the system now uses a few extra parameters to only light up a few objects at random times (and at random amounts). So now, if you have like 5 cloud objects, some clouds will light up in the distance while others done, more realistic. (Added the param descriptions below and another video as well).

</EDIT>

A while back I posted an example of how to accomplish a semi-realistic thunder/lightning effect using DBP Native Commands. I've started using it a lot in my games so I decided to turn it into a function, so here it is;



SYNTAX:

Storm# = Storm(MinAppend#,MaxAppend#,DecRate#,StartSound,EndSound,StartObj,EndObj,Probability)

MinAppend#: The shortest amount of time before the effect occurs.
MaxAppend#: The longest amount of time before the effect occurs.
DecRate#: The speed at which the counter decreases at. When the counter gets to 0 the effect occurs.
StartSound: The first sound number in a list of consecutive sounds to be played at random when the effect occurs
EndSound: The end sound number in a list... blah blah you get it.
FogFlag: (Removed)
StartObj: The first object in a series of consecutive objects to be randomly lit up
EndObj: Same as above but for the end object
Probability: The chance that an object has of lighting up (not in percentage). Increase this number to increase the chance (and in turn density) of lightning.

And finally, a video of the storm in action (shameless plug for my WIP ):



And a vid of the new function:



The above example uses these settings:

Storm# = Storm(0,50,.5,1,6,994,999,3)

And the example I gave with the other thread;





Note: To really appretiate the effect you'll need a sky sphere/box, however the function really shines with the addition of some clouds.


I might add in some lightning bolt strikes later tonight if Im bored, if not it really isn't too hard to add, just texture a plain with a lightning bolt image, point the plain to the camera, and position it off in the distance when the effect occurs.

<EDIT>

I've included 6 storm sounds in a rar file in this post's download below.

</EDIT>

Hope it helps,
- RUC'[b][/b]

Attachments

Login to view attachments
TEH_CODERER
21
Years of Service
User Offline
Joined: 12th Nov 2003
Location: Right behind you!
Posted: 6th Jul 2006 18:42
Looks pretty good. I'll try it out.

[url]andrewneale2004@yahoo.com[/url]
http://www.elbsoftware.dbspot.com
Medieval Coder
18
Years of Service
User Offline
Joined: 31st Dec 2005
Location:
Posted: 6th Jul 2006 18:51
Looks really nice! Next time we have a thunder strom i must remember to record some thunder...
I should have a thunder storm on monday or tuesday and next saturday..

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 7th Jul 2006 02:06
Yeah but what if you want lightning with the fog already on?

But I have to admit, that video looks awesome.

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 7th Jul 2006 02:54
Well usually, atleast from what I've experienced, when lightning strikes the sky is lit up to appear like daylight, so... no fog in the real world, why have it in the game? Then again, if you were really concerned about it you could switch it to disabling the fog rendering for certain objects instead, meh.

I know its extremely simple code just thought it'd be useful, thanks for all the comments.

Chris Franklin
19
Years of Service
User Offline
Joined: 2nd Aug 2005
Location: UK
Posted: 7th Jul 2006 22:19 Edited at: 8th Jul 2006 11:48
WOW THAT IS SWEET

Wow honestly this shoudl be nailed to the top

Can i add it to the ultimate dbp pack?

Platformer Compo!
WHITEKNUCKLE IS BACK! Check the wip boards for more info
Natflash Games
18
Years of Service
User Offline
Joined: 7th Feb 2006
Location:
Posted: 4th Oct 2006 21:58
This is my faveorite DBP function yet, thanks for sharing.
Also... Bump!


Check out my site for the latest on my games.
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 9th Oct 2006 22:54
Hey that storm code was pretty good ill try it out once I buy it.


And since that wa pretty cool im going to buy it next week.At first I thought it was boring and coding is too hard.

Minh Tran
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 9th Oct 2006 22:59
Hey medieval coder do you really have to record all sound?

Minh Tran
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 14th Oct 2006 20:30
I have a code that is a surprise. has anyone heard about it yet?

sync on
sync rate 30
do
cls
if mouseclick()>0
print "you are clicking the mouse"
endif
sync
if mousemovey()>0 or mousemovex()>0
print "you are moving the mouse"
endif
sync
loop

Minh Tran

Login to post a reply

Server time is: 2024-11-23 03:20:57
Your offset time is: 2024-11-23 03:20:57