Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, SBGuy, TipmyPip, ozgur), 923 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 8 of 8 1 2 3 4 5 6 7 8
Re: [contribution] Fog code C-Script version [Re: Nidhogg] #346526
11/06/10 20:15
11/06/10 20:15

C
chris_oat
Unregistered
chris_oat
Unregistered
C



can someone upload the C-Script version of the Fog again please?
Many THanks!
Edit: or better, just write the wdl code here in the forum!

Last edited by chris_oat; 11/06/10 20:47.
Re: [contribution] Fog code C-Script version [Re: ] #380476
08/18/11 07:54
08/18/11 07:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Chris do you still need this one?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: [contribution] Fog code C-Script version [Re: 3run] #380513
08/18/11 14:54
08/18/11 14:54
Joined: Jan 2004
Posts: 3,023
The Netherlands
Helghast Offline OP
Expert
Helghast  Offline OP
Expert

Joined: Jan 2004
Posts: 3,023
The Netherlands
I came across this WDL the other day on a backup disk.
Here it is to anyone interested in the old code;

Code:
DEFINE max_alpha, SKILL1;

var cam_fog = 1800;
var wind[3];

function set_alpha
{
	my.alpha=0;
	wait(1);
	my.max_alpha = INT(random(25));
	if(my.max_alpha < 10){ my.max_alpha = 15; }
	while(my.alpha < my.max_alpha)
	{
		my.alpha += 0.5*time;
		wait(1);
	}
	my.alpha = my.max_alpha;
}

function fog_wind
{
	while(1)
	{
		wind.x = (random(1) - .5)*1.5;//*.4;
		wind.y = (random(1) - .5)*1.5;//*.4;
		wind.z = random(1)*.4;//*.1;
		sleep(5+random(3));
	}
}

function move_fog
{
	var roll_speed;
	var fade_distance = 500;
	
	roll_speed = random(2)-1; 
	
	while(me)
	{
		my.roll += roll_speed*time; //roll this sprite
		
		my.x += random(20)*wind.x*time;
		my.y += random(20)*wind.y*time;
		
		if(vec_dist(my.x, camera.x) < fade_distance) 
		{
			my.alpha = min(my.max_alpha,  vec_dist(camera.x, my.x) *my.max_alpha / fade_distance);
		}
		
		wait(1);
	}
}

function autofog
{
	my.scale_x = 2.8;
	my.scale_y = my.scale_x;
	my.scale_z = my.scale_x;
	
	var cam_pos[3];
	var randint;
	
	my.passable = on;
	my.transparent = on;
	my.bright = on;
	
	//fade in slowly
	set_alpha();

   //set orientation style
	my.oriented = off;
	my.facing = on;
	
	move_fog();
	
	while(me)
	{
		if(my.alpha < my.max_alpha) { my.alpha += time; }
	//	my.invisible = off;
		vec_set(cam_pos, camera.x);
		cam_pos.z = my.z;
		
		if(vec_dist(my.x, cam_pos) >= cam_fog)
		{
		//	my.invisible = on;
			while(my.alpha > 0) { my.alpha -= time; wait(1); }
			
			my.x = cycle(my.x, camera.x - cam_fog, camera.x + cam_fog);
			my.y = cycle(my.y, camera.y - cam_fog, camera.y + cam_fog);
			my.z = camera.z - random(100) + random (200);
		}
		
		wait(5);
	}
}

function generate_fog
{
	var randint;
	var fogcount=0;
	
	var pos_place[3];
	fog_wind();
	
	while(fogcount < 250)
	{
		fogcount+=1;
		
		pos_place.x = (camera.x - random(2500)) + (camera.x + random (2500));
		pos_place.y = (camera.y - random(2500)) + (camera.y + random (2500));
		pos_place.z = camera.z - random(100) + random (200);
		
		randint = INT(Random(2));
		if(randint == 0){ ent_create("dust1.tga", pos_place, autofog); }
		if(randint == 1){ ent_create("dust2.tga", pos_place, autofog); }
	//	wait(1);
	}
}



All you need to do is call generate_fog() in your main function, and done!

regards,


Formerly known as dennis_fantasy
Portfolio - http://www.designorhea.com/
Project - http://randomchance.cherrygames.org/
Re: [contribution] Fog code C-Script version [Re: Helghast] #380518
08/18/11 16:05
08/18/11 16:05
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
This is a great code, guys! Thanks again for it, Dennis.


My Famous Quotes: "Hip hop is like a virus, infecting everyone and everything around it. Every form of media has some way,shape or form, assimilated hip hop into it." It has also mutated into other strains like, trip hop, house, rap, gangster, and conscious forms. Once you are infected with it, its with you for life."
Re: [contribution] Fog code Lite-C [Re: Helghast] #433681
12/04/13 12:27
12/04/13 12:27
Joined: Jan 2005
Posts: 282
devon UK
D
DAVIDMORETON Offline
Member
DAVIDMORETON  Offline
Member
D

Joined: Jan 2005
Posts: 282
devon UK
Hello Helghast,
Did you find the old c-script data for fog following the player?
I am working in c-script as most of the game is in c-script(over the years!)
If you have it, I would be most grateful for a copy.
David
JUST FOUND THE CODE ABOVE-DON'T KNOW HOW I MISSED IT !!

david@davidmoreton1.wanadoo.co.uk

Last edited by DAVIDMORETON; 12/04/13 12:29.
Re: [contribution] Fog code Lite-C [Re: DAVIDMORETON] #436082
01/18/14 20:03
01/18/14 20:03
Joined: Apr 2005
Posts: 1,988
Canadian, Eh
DLively Offline
Serious User
DLively  Offline
Serious User

Joined: Apr 2005
Posts: 1,988
Canadian, Eh
So I went to the first Page of this thread and just downloaded the Lite-C version not knowing there was already a C-Script version on this page.. Whatever. I converted it back to C-Script laugh. It now looks as good as it should with the newer updated Lite-C version. I couldn't tell you for sure cause I don't program with it ^_^ Here is the code.

Edit: I also wanted to mention the FPS is great, on my low end staples pc.. Never tested it on my good pc yet wink

Code:
define max_alpha, skill1;
define max_fog, 250;

var cam_fog = 500; // needs to be a variable so it can get closer and further away to the camera as needed
var wind[3];

function set_alpha() 
{
	var fade_speed = 0.5;
	// fade model in
	my.alpha=0;
	my.max_alpha = integer(random(30));
	if(my.max_alpha < 10){ my.max_alpha = 15; }
	
	while(my.alpha < my.max_alpha)
	{
		my.alpha += fade_speed*time_step;
		wait(1);
	}
	my.alpha = my.max_alpha;
}

function fog_wind()
{
	while(1)
	{
		// new wind direction...
		vec_set(wind.x, vector((random(0.5) - .25)*1.5, (random(0.5) - .25)*1.5, random(1)*.4));
		//wait(-1 + random(3));
		wait(1);
	}
}

function move_fog()
{
	var roll_speed;
	var fade_distance;
	fade_distance = cam_fog+(cam_fog/7);
	var fog_speed = 20;
	
	roll_speed = random(2)-1; 
	
	while(me)
	{
		my.roll += roll_speed*time_step; //roll this sprite
		
		// update position globally
		c_move(my, nullvector, vector(random(fog_speed)*wind.x*time_step, random(fog_speed)*wind.y*time_step, 0), IGNORE_PASSABLE);
		
		// fade sprite when close to camera
		if(vec_dist(my.x, camera.x) < fade_distance) 
		{
			my.alpha = minv(my.max_alpha, vec_dist(camera.x, my.x) * my.max_alpha / fade_distance);
		}
		
		wait(1);
	}
}

function autofog()
{
	var cam_pos[3];
	var randint;
	
	vec_scale(my.scale_x, 0.8);
	my.passable = on;
	my.transparent = on;
	//fade in slowly
	set_alpha();
	move_fog();
	
	while(me)
	{
		if(my.alpha < my.max_alpha) { my.alpha += time_step; }
		
		vec_set(cam_pos, camera.x);
		cam_pos.z = my.z;
		
		if(vec_dist(my.x, cam_pos) >= cam_fog)
		{
			// fade the fog out
			while(my.alpha > 0) { my.alpha -= time_step; wait(1); }
			
			// set on new position at edge of fog distance
			vec_set(my.x, vector(cycle(my.x, camera.x - cam_fog, camera.x + cam_fog), cycle(my.y, camera.y - cam_fog, camera.y + cam_fog), camera.z - random(100) + random (200)));
		}
		
		wait(5);
	}
}

var fogcount;
function generate_fog()
{
	var randint; // random fog sprite
	
	var pos_place[3];
	
	fog_wind(); // sets a random fog position every so often
	
	if(fogcount<250)
	{
		// set random position around camera
		vec_set(pos_place.x, vector(((camera.x - random(cam_fog)) + (camera.x + random(cam_fog))), ((camera.y - random(cam_fog)) + (camera.y + random(cam_fog))), ((camera.z - random(cam_fog/8)) + random(cam_fog/4))));
//		vec_set(pos_place.x, nullvector);
		
		// get a random number
		randint = integer(random(2));
		// create different fog, based on random number
		if(randint == 0){you=ent_create("Dust_1.tga", pos_place, autofog);you.passable = on;}
		if(randint == 1){you=ent_create("Dust_2.tga", pos_place, autofog);you.passable = on;}
		fogcount += 1;
	}
	else{return;}
}


And in the function main()
Code:
function main(){
...
while(1){wait(1);
if(fogcount<250){generate_fog();}
}
}



If anyone could help make it better so that it doesn't update so slowly, that would be cool. I find that when my player moves away it doesn't update around him fast enough.

Last edited by DevoN; 01/18/14 20:11.

A8 Pro 8.45.4
YouTube: Create Games For Free
Free Resources: www.CGForFree.com
Page 8 of 8 1 2 3 4 5 6 7 8

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1