add more 'realism' to night scene with stars

Posted By: Lion_Ts

add more 'realism' to night scene with stars - 09/22/05 21:10

Hi!
For night scene may be usefull this piece, to add some 'blinking' stars:
Code:

...
bind <stars_.tga>;
sky skycube {
type = <sky+6.tga>;
flags = cube,visible;
z=-5; layer = 1;
}
sky stars {
type=<stars.tga>;
flags = dome,visible;
scale_x=0.4;
layer=3;
}
...
starter blinking_stars{
while(1){
ent_morph(stars,"stars_.tga"); //morph to shine stars
waitt(random(15)); //play with this
ent_morph(stars,"stars.tga"); //morph back
waitt(random(9)); //play with this
}
}


provide your stars.tga with 'normal' stars and stars_.tga, where some stars a slightly changed in size/brightness/color.
P.S.
You can use ent_morph with different engine objects, not bmaps only.
Posted By: Josh_Arldt

Re: add more 'realism' to night scene with stars - 09/22/05 21:29

Cool idea.
Thanks
Posted By: tuschcarsten

Re: add more 'realism' to night scene with stars - 09/22/05 21:31

Sounds interesting

Good Idea
Posted By: XNASorcerer

Re: add more 'realism' to night scene with stars - 09/22/05 22:33

Thanks for you contribuition.
Posted By: Anonymous

Re: add more 'realism' to night scene with stars - 09/22/05 23:18

Thanks LionTs, you're always contributing, that's awesome. I think you need some closing parentheses on those waits though ))
Posted By: task1

Re: add more 'realism' to night scene with stars - 09/23/05 09:20

nice! I īll try it!thanks alot
Posted By: EX Citer

Re: add more 'realism' to night scene with stars - 09/23/05 12:18

Thatīs a bad code. Itīs not working the same on different pcs. I hope not all your codes are like that you published here.

wait(random(x)); <<< this will cause a flickering on a 3ghz comp minigame, and anything but not blinking on a 60khz cpu.

use sleep

I am afraid that many games here are full of such "not time fixed" code.
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/23/05 12:39

Quote:

Thatīs a bad code. Itīs not working the same on different pcs. I hope not all your codes are like that you published here.
wait(random(x)); <<< this will cause a flickering on a 3ghz comp minigame, and anything but not blinking on a 60khz cpu.
use sleep
I am afraid that many games here are full of such "not time fixed" code.



It's true I forget it. I'm posting from internet-cafe, not from my home, where my 3dgs installed. I looked at my code, I'm using waitt(random).
Sorry for that.
TO WING: Thank you, code changed.
Posted By: ello

Re: add more 'realism' to night scene with stars - 09/23/05 13:49

well, waitt(x) isnt in the manual anymore so i think its gonna be removed?? i didnt use waitt one time
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/23/05 14:08

Yeah, but it worked. So, have I to use sleep instead ?
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/23/05 21:07

Another example.
We have same night and stars... Rain and moon...
Ok, add some more 'realism' - add flare to moon and change it when rain is on.
Code:

...
sky moon { //moon
type=<bmoon.tga>;
flags=visible,transparent;//,transparent,overlay;
alpha=100;
x=500; //play with this and all below
y=-130;
z=100;
scale_x=0.25;
scale_y=0.25;
scale_z=0.25;
layer=5;
}
sky moon_flare { //moon
type=<bmoonflare.tga>;
flags=visible,transparent;
alpha=100;
x=500; //pos to moon
y=-130;
z=110;
layer=10;
}
...
//somewhere in your code
...
while(1) {
while(RAIN==on) {
//your rain code here
...
if (moon.alpha > 50) { moon.alpha-=time; }
moon.alpha = max(moon.alpha,0);
if (moon_flare.alpha > 50) { moon_flare.alpha-=time; }
moon_flare.alpha = max(moon_flare.alpha,0);
wait(1);
}
if (moon.alpha < 100) { moon.alpha+=time; }
moon.alpha = min(moon.alpha,100);
if (moon_flare.alpha < 100) { moon_flare.alpha+=time; }
moon_flare.alpha = min(moon_flare.alpha,100);
wait(1);
}


What is this ?
When rain is on - flare around moon slightly 'muted'.
Try, you'll like it
Posted By: EX Citer

Re: add more 'realism' to night scene with stars - 09/24/05 05:17

You shoudlnīt use waitt because itīs ld code. I thought itīs already removed. I hope you are working with the latest update. Noobs who get an error message with waitt could think itīs a typing mistake you made and write wait instead what will work but be wrong.

sleep(0.5); ~ 0.5 seconds
Posted By: TripleX

Re: add more 'realism' to night scene with stars - 09/24/05 15:57

waitt will be removed within the next update. Use sleep instead.

Triple-X
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/24/05 17:30

Ok, i understand.
Thank you.
Posted By: bupaje

Re: add more 'realism' to night scene with stars - 09/25/05 17:56

Thanks for the cool effects code. All those little details add to the realism of the scene.
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/25/05 18:45

Thank you bupaje. Sorry for offtopic, but i have to say. Your photo(avatar)! This is me. This isn't a joke , my beard slightly smaller...
And I like beer. You are ?
Posted By: bupaje

Re: add more 'realism' to night scene with stars - 09/25/05 21:57

Quote:

...i have to say. Your photo(avatar)! This is me. This isn't a joke , my beard slightly smaller...
And I like beer. You are ?




Well I don't have the red nose and I shaved the beard. Use to wear it when I lived in a colder place. In California just itchy and now it has too much gray. I no longer drink - was only a social drinker; gave it up about 15 years ago.

From the "Post Your Photograph" thread in Morbius you can see my current mug shot.

http://bfenter.com/burtstuff/slow_decline.jpg
Posted By: Damocles

Re: add more 'realism' to night scene with stars - 09/25/05 22:01

To the waitt:

It is much more useful to me than sleep,
since I do not know how precise sleep will be in really
small time fractions.
I dont see a sense in removing waitt...
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/25/05 22:27

Bupaje, I know now, how I'll looking after 10 years
To Damocles:
Well, you are right. sleep(0.005) ? May be try to measure sleep execution ?
Posted By: Anonymous

Re: add more 'realism' to night scene with stars - 09/26/05 05:50

Depending on how fast a PC is, if FPS is 300, then in a loop, you game will go through the loop 200 times.

If you still want to use waitt(), consider this:

Since there are 16 ticks per second with the waitt function, what you can do is use sleep. If you want a 16-tick precision from a waitt function, divide 1 by 16. That gives you 0.0625. So you can do this in a while loop:

sleep(0.0625);

But, there's another way: using a time variable for wait function.

wait(16) * time;

Since you want to have 16 ticks per second, all you have to do is substitute 16 for wait and multiply by time.

However, since I've tried the wait(16)*time with fps_max, I get different results. Same with sleep, too, so it's not a good ideal to use fps_max as there can be users who wanted to have a faster frame rates per second (in other words, smooth game play).

I'm not sure if the wait(16) * time can be affected by the frame rate, so I only test it with a blank level (a very small hollow cube) and my fps is pretty high. So go ahead and test it:

string _level = <time.wmb>;

font myFont = "Tahoma", 1, 16;
var myVar = 0;

Code:

panel myPanel
{
digits = 20, 20, 2, myFont, 1, myVar;
flags = visible;
}

function main()
{
level_load(_level);;
while(1) // Once the myVar goes up to 16, reset to 0 ans start again.
{
while(myVar < 16)
{
myVar += 1;
sleep(0.0625); // This makes up 16 ticks.
}
myVar = 0;
}
}



Change the code if you like (the level name, for example).
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 09/26/05 13:47

Thank you, Grayson Peddie. I'll try that.
Posted By: Matt_Aufderheide

Re: add more 'realism' to night scene with stars - 09/30/05 05:41

I thought sleep made the whole program stop.. or is that changed?

man..i wish they would stop changing things like this.
Posted By: EX Citer

Re: add more 'realism' to night scene with stars - 09/30/05 13:19

freeze stops everything. Sleep never stopped everything and worked always like waitt (never saw it working different)
Posted By: KoH

Re: add more 'realism' to night scene with stars - 10/15/05 12:41

can someone upload some screenshots
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 10/15/05 21:15

For what ? Blinking stars ?
Posted By: Sinthoras

Re: add more 'realism' to night scene with stars - 10/16/05 10:29

btw, @all "sleep" users:
i saw that thread, it might be important for you:
sleep replaced by wait

the posts of jcl are the important ones:
Quote:

Sleep wurde, wegen des gleichnamigen Windows-Befehls, sowieso ab 6.31.4 durch wait() ersetzt, so dass sich dieses Problem nicht stellt. Aber auch in 6.31.4 ist die Mindestwartezeit von einem Frame gewaehrleistet.


and
Quote:

wait (var);
Pauses the current function for a number of frame cycles or seconds.

Parameters:
var - number of frames when positive, wait time in seconds when negative. Maximum value is +/-1000.


Sinthoras
Posted By: Lion_Ts

Re: add more 'realism' to night scene with stars - 10/16/05 10:35

Thanks. I'll try that.
Posted By: KoH

Re: add more 'realism' to night scene with stars - 10/16/05 10:49

Can someone upload some screenshots of this code working as I don't have time to try it myself.

Thanx
© 2024 lite-C Forums