Go to content

Main menu:

Choosing the Variables to Save - Components of a Level Editor

Last Updated: February 7th, 2015
A level editor, at its most fundamental level, can be viewed as the integration of three engine mechanics: creating a level, saving a created level, and loading a saved level. This tutorial is broken down into three sections with each section describing one of the engine mechanics listed above. Each section will describe the concept, goal, and several ways of achieving the section’s mechanic in Multimedia Fusion 2 and Clickteam Fusion.

Concept for Saving the Level
If you have followed the previous sections of this tutorial series, you should have the design aspect of your level editor completed, which leads you to the saving aspect. If you have chosen not to follow the previous section of this tutorial series, do not worry, this section of the tutorial series discusses the saving aspect of level editors in a general sense.

When considering the saving aspect of any program, you should list all of the important variables which need to be maintained or saved. The purpose of saving variables is to later load them into some object. For level editors, saved values are typically loaded into objects as soon as the level starts. From there, the game engine executes until some other variables need to be saved, at which point the process repeats.

In the context of a software tool, these variables might be related to user settings or configurations. In the context of a software game, these variables might be related to player data (such as player’s name), level data (such as a level’s high score), or game data (such as player names). In either context, it is evident that these variables are important and filtering the important variables from the unimportant variables is a useful technique.
Choosing the Critical Variables
For this tutorial, critical variables are variables which are needed for a character, level, or game to run properly.

Outside the context of a level editor, critical variables are the sets of data needed for the the application or for specific application mechanics to execute as intended. Examples include user configurations, application preferences, and local application data.

Within the context of a level editor, critical variables for any given level are the objects used in the level. Imagine trying to load or play a level but you have no idea as to what objects should be included in the level! So you have decided that for a given level editor level, it is important that you save every object used in the level. Great! Now, what are the critical variables for these objects? It should be evident that two critical variables are the x and y coordinates. Without these variables, you would have no idea where to put objects for the level editor level! As such, the x and y coordinates are critical variables for the level editor objects. Other critical variables may include the object’s initial direction, object’s angle, and object specific variables such as HP or speed. As a rule of thumb, variables whose initial values generally differ between instances are prime candidates for critical variables!
Implications of the Critical Variables
Similar to when making decisions about other subjects, there are implications when deciding on the critical variables, listed below.

Having extremely few critical variables makes the saving and loading aspects easier, but limits user customization. Everything not saved as a critical variable thus must be initialized with some default value. If you, for example, only define an enemy’s critical variables as its x coordinate and y coordinate, then everything besides the enemies’ x coordinate and y coordinate will be the same. Same initial direction, initial speed, movement type, and so forth. The user will not be able to design a level with enemies initially facing different directions or varying initial speeds.

Having large amounts of critical variables allows for user customization, but increases the difficulty of saving and loading levels with the level editor. More critical variables means more code to accommodate each critical variable. Failing to save or load even one critical variable may result in an unplayable level.

You, the developer, need to strike a good balance of critical variables, ultimately providing suffice customization within your coding skill level.
Example of a Critical Variable Hierarchy
Click to enlarge image and view description
Rate This Tutorial
Vote: 4.0/5
If you have read this tutorial, rate it from poor (1) to average (3) to great (5)!
Back to content | Back to main menu