Multiple Levels

From Game Editor

Jump to: navigation, search

There are several ways to approach multiple levels, and even then, one level can be composed of many sub levels. The two main ways to make multilevel games are, Activation Regions, separate game files. Activation regions are not necessary for multiple levels, as it is possible to use just one of the main ideas of activation regions while still making separate levels. Another, less commonly used method, is to load levels through exterior files such as txt files.


Basics

The main concern about making multiple levels is unnecessary processing. When you make just one level, it probably won't have that much of an impact, but as you add more levels, you are adding more events that most be processed each frame. There are some easy tricks to prevent this, the most basic would be to switch the actor to not receive events out of view. This is actor specific, so it can help a lot, but it does have its flaws. If all actors do not receive events out of view, then the game can lose an aspect of fluid game play. The fix for this would be either to split the games into separate ged or exe files, a level in each environment, or to use Activation Regions. The general idea behind them is any actors within a region essentially do not exist. As soon as the view enters an activation region, all actors within the region turn on. This is not completely true, as actors can be addressed, they just do not act upon any of their events unless view is within the region they exist in.

Multiple Files

gameEditor has a built in function called LoadGame. Using this, you can load a new ged or exe. This allows you to hold completely different environments, while minimizing the complexity of an individual game. This can be used for each individual level, or used in a combination with Activation Regions. A problem with this method is the need to recreate the actors and all variables, events, and anything else for each level. To avoid this, you can save the first level as a template, and edit those levels, saving them as new levels. Another way is to edit the most recent level, destroying the old level while keeping the actors. It really depends on how you build the level.


LoadGame is a simple function. This example will demonstrate how to set up a simple level changer. This is possible with indexed levels, but it involves char manipulation. Since using this function will use completely separate ged files, you can simply use the name of the next level.


Level00.ged You will have your first level layed out in the ged. In this example, the defining level change is a door at the end of a level. The player has a collision event, checking for keydown up, triggering the load of the next level.

Player -> Collision(door) -> Script Editor

char * key = GetKeyState();
if(key[KEY_UP]==1)
{
    LoadGame("Level01.ged");
}


It is not necessary to specify the file type, but it is good practice, as it will pull the first name it finds, whether it be ged or exe. This method is a simple method as it does not consider several factors. One main one is the transfer between level 2 to level 1, and other. The keydown event is non biased from what door will trigger the event. You also need to change the code for each level. This is fine in lots of games, but for those that desire multi level changing, there are several ways to approach it. The biggest one is to LoadVars. This will be necessary for almost any game using LoadGame.


Will Continue Later