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 / Day and Night, rain,snow .. How?

Author
Message
Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 17th Apr 2006 12:59
How would i get all these things to work in a cycle so I could use them in my game?

Any code would be nice

Twu Kai
19
Years of Service
User Offline
Joined: 2nd Oct 2005
Location:
Posted: 17th Apr 2006 13:59
I've made some code for day/night and rain, here they are:

Day/Night


Rain


I hope that it's of some use to you!

Join The Clan! http://www.torak.info

Desteya colatiata hethayas thorian helltastha lutanithan atelthuron ilonthes!
Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 17th Apr 2006 14:27
Ok thanks for the code but the day and night cycle didn't do anything and the rain was too fast, is there anyway to change this?

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Apr 2006 15:15
Yes it does you just have to wait a bit, increasing the speed# value will make the cycle go faster;



Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 17th Apr 2006 15:38
Thanks, now just things like rain and snow

Mr X
19
Years of Service
User Offline
Joined: 25th Sep 2005
Location: Universe, milkyway, sol-system, Earth...
Posted: 17th Apr 2006 16:30 Edited at: 17th Apr 2006 16:35
A tip about the rain. Make it to a function. You can then use global variables or arrays to manipulate the rain speed, intencity etc. The reason for having it as a function (lets call it "rain()") is that it will be MUCH easier to controll. Youll just use the command "rain()" everytime rain is needed.

And here is an snow example (mostly the same thing as the rain but only thicker dots):



EDIT:

A rain function would be the same, but with only one "dot".
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 17th Apr 2006 16:43 Edited at: 17th Apr 2006 16:43
As far as rain or snow goes you have 2 main options; 2D or 3D.

For 3 dimensional, you would have a spawn point for the rain somewhere high in the sky, and this spawn point generates the rain objects. By generating, I mean positioning a pre-loaded rain model at the spawn point, moving it on the x and z axis some random amount so that the drops dont all fall in the same place, and then allowing them to fall down. After the rain hits the ground you'll want to reuse as much as you can to prevent lag, so instead of making more rain objects constantly you'd just reposition the rain droplet that hit the ground back at the spawn point and start the process all over again. You might also want to give the droplets varying speeds for more realism.

The problem with 3D is that you will most likely get a lot of lag; even with one sided plains you're usually talking about a hundred or more droplets falling at once. The work around for this would be to only drop the rain when the user is looking somewhere the rain is visible (using the OBJECT IN SCREEN command), hiding rain that is a certain distance away (though using the common 3D distance formula is laggy, you'd probably want to look into vectors for this, though they can get very confusing).

The pro's however being that its much more realistic and usually easier to deal with than 2D. When you look up, rain will fall into your face; this usually isn't the case with 2D. Also the rain droplets get smaller in the distance providing even more realism.

As far as 2D goes the theory is almost the same. Instead of a 3D model you'd load a 2D picture ofa rain droplet, position it at the top of the screen at some random point on the x axis, and move it downwards. When it reached the bottom, you'd move it back up again and repeat the cycle. Like I said before though, much less realistic, but thats up to you.

Another workaround could be to create maybe 3 or 4 large images of rain falling at different stages, the size being equal to the size of the user's screen. Then instead of repositioning/moving the rain droplets, all you'd do is place the images in the center of the screen and cycle throw them rapidly.

Dont have much more time to respond to the threads for the morning but here's an extremely basic version of the 2D rain.



Play around with it until you understand it.

- RUC'

Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 17th Apr 2006 22:47
Rain is very easy for me!

All you have to do:
Get a texture of rain with a complete black background
Make a plain
Texture the plain with the rain image
Set transparency on that plain
After sync set a variable depending on Timer()
And scroll the rain texture on the Y axis with the variable
Place the rain plain in front of the camera.


As for the Day/Night, I modified the code a little bit:

make object cube 1,50
time#=70.001
speed#=0.01
day=1
night=0
dn=day
do
if time#=>70.001 then dn=day
if time#=<0.001 then dn=night
if dn=day then time#=time#-speed#
if dn=night then time#=time#+speed#
set ambient light time#
color backdrop time#
loop




Wa la!

"Forgiveness is a good thing"
"Forgiveness is between them, and God. I set up the meeting"
-Man on Fire
Digital Dragon
19
Years of Service
User Offline
Joined: 17th Dec 2004
Location: ...
Posted: 18th Apr 2006 00:30
kool thanks

Login to post a reply

Server time is: 2024-11-27 21:42:07
Your offset time is: 2024-11-27 21:42:07