Note~DEC Stuff is Dan Cook, the user who originally wrote this article.
1:Ever wanted to make a game, and make a level editor for it? The idea popped in my head today. It's simpler than you think.
You will need MMF to make it...
You game will have to have it's levels in grid mode, but it is possible to load levels they will have to be in grid mode.
It's somewhat simple, Once you get the hang of it.
First you make a tile selection system. Then divide your level up into a certain amount of squares. In this example we will say X is 15 and Y is 10. Now make a tile placing system(I usually use the keyboard. Make a flashing block or something to indicate where the tile will be placed...and add the following events so your block indicator will move to a selected place in the grid.
Upon pushing Down...move Flashing block placing indicator Down from it's current position+15(or whatever the size of your grid blocks is.
Do this with all directions-
Make it so when you push enter an active of your backround is created and a backround picture is placed, then the active is destroyed.
Here comes the tricky part.... Create an array and set it to the exact dimensions of your level(the size of the grid~X,Y)
When the user pushes DOWN...in the array the current position of Y is changed to Y's current position +1.
When the user pushed Right...in the array the current position of X is changed to X's current position +1.
Do the same thing with Up, and Left(except negatives)
Now...write this down. Assign each tile with a number.
When ENTER is pressed the number of the selected tile is placed in the grid.
Finally add a save button...and make it so you can save the Array...
LOADING THE ARRAY...
When a user loads the array...make it so that in the first few seconds an active is created in all the gridspots with numbers purtaining to that tile. Then make them create backround obstacles, and your level is loaded! (You may want to try to use the fastloop object for this part...but your on your own for that)
Making all the tiles load can be tricky. You might try the following.
Make an Active, and create all your tiles as animations within it.
Put in the following actions...
-ALWAYS>Place tilemaker at Tilemakers position +15(or the Height of your tiles), And Add one to Y dimension of array.
*when tile maker is visible
Now you need to make an action for each tile you have.
Read value from array...
*If Value =1 Set animation of Tilesetter to TILE 1.
Then place this action.
Every 00:02(or something similar) Place a backround picture of Tile Setter as an obstacle...
THERE YOUR DONE>....Hope it's not terribly confusing(by the way...I thought this hole thing up in about 3 seconds....literally---not joking)
Yeah, i've seen (and made) one with a mouse and grid in tgf.
But the tricky part is to paste the backgrounds in the right way, not a big tree in front of a little one,
that kind of things.
Once people get to grips with coordinates, etc, they can also save individual object parameters. You need a string array for that though, so AssArray will be better than CNC Array (since CNC Array doesn't encrypt files).
I tend to use 1-dimensional arrays (aka: List objects), and do the encryption manually. Each line generally looks like this:
x, y, object_type, param1, param2, param3, ...
x, y, object_type, param1, param2, param3, ...
x, y, object_type, param1, param2, param3, ...
x, y, object_type, param1, param2, param3, ...
Unfortunetely, I started off with MMF(well that was the first FULL version "click" software I had) And Once I had MMF, I took a look at TGF and found it to be too basic for me. It would probably be harder in TGF than in MMF to make a level editor because you have to take a different, more difficult route to get there.
Yeah, this same technique has been said many times. Btw you should use floop for the loading otherwise it takes a dang long time if you have huge maps *Ugh* I hate that.
Spiderhead: It's harder in TGF because of TGF's limitations. There are two ways that you can make the level editor work: Creating actives, and creating backdrops.
The only way to create a backdrop in TGF at runtime is to use 'paste into background' action. The problem is that these get wiped when the frame is redrawn (when you scroll, for example).
Creating actives is also inefficient because of TGF's object limit, and slowdown.
To build a working one in TGF, you'd need an array/list with the location and variables of each object. When the player moves, the list is checked and any objects whose location is within the screen area are created. When they go out of the screen, the information in the list is updated if necessary, and then the object is removed. This keeps object limit down.