Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, dr_panther), 1,290 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Creating a Basic Shoreline with Script (WDL) #311001
02/18/10 05:27
02/18/10 05:27
Joined: Jan 2006
Posts: 245
PA
Garrettwademan Offline OP
Member
Garrettwademan  Offline OP
Member

Joined: Jan 2006
Posts: 245
PA
I figured this would be right place to put this topic. I was looking for a way to make a real basic shoreline effect on my terrain where it meets the ocean/water, here is what I came up with.



I am doing a simple scan on the map to find the edges and where there should be some white water. You can download the code and TGA file I used for this script. You can of course improve on this if you wish. If used efficiently, it won't tax your system to much. I found if you abuse it, it can drop the FPS of your game fairly quick. Well, here is the poor man's shoreline info. Hope you find a place to use this.

http://www.garrettwademan.com/3dgs/shoreline/shoreline.zip

Here are the two functions I used, just adjust the variables and call "find_shore_line".

Code:
function wave_control(){
	my.transparent = on;  //Make shore line a transparent
	my.red = 255;  //Adjust colors, this may not do anything depending on which water you are using
	my.blue = 255;
	my.green = 255;
	my.tilt += 90;  //Tilt the TGA file so it is flat
	my.bright = on;  //Add brightness to the TGA file
	my.ambient = 100;  //Ambient look
	my.albedo = 100;  //Albedo look
	
	while(1){
		wait(random(50));  //Add some random wait time so it doesn't look syncronized
		my.scale_x = 0.5;  //Start scale at half size, you can adjust this to your needs
		my.scale_y = my.scale_x;
		my.alpha = 100;  //Start out as 100 alpha value, change this to your needs
		while(my.scale_x < 10){  //Go until the size = 10, adjust this to your needs
			my.alpha -= 0.3;  //How fast this TGA shore line fades		
			my.scale_x += 0.03;  //Make the shore line effect larger as time goes on
			my.scale_y = my.scale_x;
			wait(1);
		}
		wait(1);
	}
}

function find_shore_line(){
	var start_x = 0;
	var start_y = 0;
	var height = 0;
	var old_height = 0;

	start_x = 0;  //This is where you want to start scanning, this should be on the corner of your map at the lowest value
	start_y = 0;  //Same as above, except on the y axis
	
	while(start_x < 80000){  //Set this number "80000" to the max scan on the X axis
		while(start_y <= 15000){  //Set this number "15000" to the max scan on the Y axis
			old_height = height;  //Take note of the old height checked
			
			//For the code below, start scane for height of water line.  The 1975 will be 25 quants above the water line and 1950 is the
			//water line itself, you can adjust the 1975 to a number just right above your water line, and 1950 to your water line or just
			//1 or 2 quants below water line, up to you
			height -= c_trace(vector(start_x,start_y,1975), vector(start_x,start_y,1950), ignore_sprites + ignore_passable + ignore_flag2 + ignore_models);
			
			if(old_height != height){  //If this scan senses a change in height because start of terrain, execute below code
				ent_create("shore.tga",vector((start_x + 0),start_y,1950.5), wave_control);  //Create the shoreline, only change the 1950 to match your water level
				old_height = 1950;  //Reset the old height to your water line
				height = 0;  //Reset your height check
			}			
			start_y += 100;  //This will scan every 100 quants on the Y axis
		}
		
		start_x += 100;  //This will scane every 100 quants on the X axes
		start_y = 0;  //Reset the Y scan to begin over again using a different vector
		wait(1);
	}
}



Last edited by Garrettwademan; 02/18/10 05:30.

Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com
Re: Creating a Basic Shoreline with Script (WDL) [Re: Garrettwademan] #311065
02/18/10 14:12
02/18/10 14:12
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Awesome contribution! I am glad to see you are still at it! your pesistance gives me hope, maybe one day i can finish my project.


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: Creating a Basic Shoreline with Script (WDL) [Re: Blink] #311135
02/18/10 17:22
02/18/10 17:22
Joined: Jan 2006
Posts: 245
PA
Garrettwademan Offline OP
Member
Garrettwademan  Offline OP
Member

Joined: Jan 2006
Posts: 245
PA
Hey there. Yea, I am still whacking away at the game. I am expanding my terrain even more this time to get more land. It is a slow process, but every line of code will get me closer to the end.


Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com
Re: Creating a Basic Shoreline with Script (WDL) [Re: Garrettwademan] #311144
02/18/10 17:39
02/18/10 17:39
Joined: Feb 2010
Posts: 457
Norfolk,England
mikaldinho Offline
Senior Member
mikaldinho  Offline
Senior Member

Joined: Feb 2010
Posts: 457
Norfolk,England
thanks for the wonderful script man! this will help me so much.

Re: Creating a Basic Shoreline with Script (WDL) [Re: mikaldinho] #311145
02/18/10 17:43
02/18/10 17:43
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Good luck! I am looking forward to seeing the results.


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: Creating a Basic Shoreline with Script (WDL) [Re: Blink] #311147
02/18/10 17:44
02/18/10 17:44
Joined: Feb 2010
Posts: 457
Norfolk,England
mikaldinho Offline
Senior Member
mikaldinho  Offline
Senior Member

Joined: Feb 2010
Posts: 457
Norfolk,England
are you saying good luck to me or to Garettewademan?

if to me thanks for that.

Re: Creating a Basic Shoreline with Script (WDL) [Re: mikaldinho] #311485
02/20/10 00:11
02/20/10 00:11
Joined: Jan 2006
Posts: 245
PA
Garrettwademan Offline OP
Member
Garrettwademan  Offline OP
Member

Joined: Jan 2006
Posts: 245
PA
As I have been working more with this, I have realized that if you want to improve the speed of the game, you can change the WAIT value in the following loop.

Code:
while(1){
		wait(random(50));  //Add some random wait time so it doesn't look syncronized
		my.scale_x = 0.5;  //Start scale at half size, you can adjust this to your needs
		my.scale_y = my.scale_x;
		my.alpha = 100;  //Start out as 100 alpha value, change this to your needs
		while(my.scale_x < 10){  //Go until the size = 10, adjust this to your needs
			my.alpha -= 0.3;  //How fast this TGA shore line fades		
			my.scale_x += 0.03;  //Make the shore line effect larger as time goes on
			my.scale_y = my.scale_x;
			wait(5);
		}
		wait(5);
	}




Current Project: Computer Repair Simulator
https://www.computer-repair-simulator.com
Re: Creating a Basic Shoreline with Script (WDL) [Re: Garrettwademan] #311536
02/20/10 13:08
02/20/10 13:08
Joined: Jan 2006
Posts: 2,157
Connecticut, USA
Blink Offline

Expert
Blink  Offline

Expert

Joined: Jan 2006
Posts: 2,157
Connecticut, USA
i was talking to garrett.


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: Creating a Basic Shoreline with Script (WDL) [Re: Blink] #311587
02/20/10 19:22
02/20/10 19:22
Joined: Feb 2010
Posts: 457
Norfolk,England
mikaldinho Offline
Senior Member
mikaldinho  Offline
Senior Member

Joined: Feb 2010
Posts: 457
Norfolk,England
oh. ok. i was only asking


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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