Level Load Behavior

Posted By: mschoenhals

Level Load Behavior - 01/30/14 17:29

I have created a level load behavior that works fine to load the second level. Trouble is, I want to create more than one level and that would mean creating a different behavior for each level. I'd like to create a behavior that brings a up a pop-up that I can type in the name of the new level (and thus not code a different behavior for each level).

Here's what I have so far:
Code:
function level_Change() { 
	
	while(1){ 
	
		if(event_type == EVENT_PUSH){
			wait(3);
			level_load("shooter.wmb");  //use this if you are making level 2
			wait_for(level_load);  //use this if you are making level 2
			return;					//use this if you are making level 2
		}	
		
		wait(1);
	}
}
action touch_Entity() { 
	my.emask = ENABLE_PUSH;
	my.group = 2;
	
	while(1){
		wait(1);
		my.event = level_Change; 
	}
}


Any ideas would be really appreciated!
Posted By: Superku

Re: Level Load Behavior - 01/30/14 17:35

There are (of course) multiple ways to do this, for example these two:

Code:
void level_Change()
{ 	
	if(you == player) my.skill10 = 0;
}

action touch_Entity()
{ 
	my.event = level_Change; 
	my.emask |= ENABLE_PUSH;
	my.group = 2;
	
	my.skill10 = 1;
	while(my.skill10) wait(1);
	level_load(my.string1);
}


Here you can enter the name of the next level in the entity's first string field in WED.

Other approach:
Code:
TEXT* txt_level_names =
{
	string("shooter.wmb","outdoor.wmb");
}

void level_Change()
{ 	
	if(you == player) my.skill10 = 0;
}

//skill1: level_id 0
action touch_Entity()
{ 
	my.event = level_Change; 
	my.emask |= ENABLE_PUSH;
	my.group = 2;
	
	my.skill10 = 1;
	while(my.skill10) wait(1);
	level_load((txt_level_names.pstring)[my.skill1]);
}


Here you can use a text object as an easy way to realize a string array, then write your level names into the string parameter and then use the first entity skill as an index to load the appropriate level.
Posted By: mschoenhals

Re: Level Load Behavior - 01/30/14 17:45

Thanks for the response.
I put the code in and entered shooter.wmb in the first string. Now I only get a sky box when I come into contact with the entity.
Posted By: Superku

Re: Level Load Behavior - 01/30/14 18:07

Then debug your code/ game/ level and try to isolate the problem.
© 2024 lite-C Forums