How To Create A Level Editor
Author: | Sumo148
|
Submitted: | 21st April, 2009
|
Views: | 8974
| Rated: |
|
|
Now, I know there are multiple "level editor" tutorials on the daily click, but most of them are outdated and confusing. I'm going to show you how to make a level editor using the Array object in Multimedia Fusion 2. Note: there are alternative medthods using the INI object for all you TGF users!
The Idea
First off I want you to know how the level editor will actually work, so you know what your doing. There will be two basic frames. One frame is the "creation frame" while the other is the actual "game frame". While in the first frame the user presses buttons to change the object that they can create. Then they "paint" the selected object on a grid representing a level. Note: the level editor will have to be in a grid formation, so it's best to have sprites that have the same length and width (ie. 32x32, 40x40,). Every time a item is created on the grid, a number gets written on an array that corresponds to the grid. Each active will have a specific number. For example if you create a horizontal wall and the number is 1, when the person creates it a one will be written in the array...
Setting It Up
You will need a few extensions. Some you may have to download off the internet. I suggest this site: http://clickteam.info/neatwares/extensions/ The objects that you will be using are:
Active
Easy Grid
Array
Button
Common Dialogue Object
Quick Backdrop
File Object
Counters
Strings
And a few other extensions that come with Multimedia Fusion 2
Okay, so once you have all of those objects, it's time to start. First, go to a normal level you have in your game. Figure out the dimensions of the level and then figure out a width and height of a tile size that would be appropriate. A good tile size would be 30x30. Copy a level from your game and rename it "Level Editor". Now you should have all the same objects on the frame you just duplicated. Try to make all the objects the same size. You could either create a whole entire different tile or just shrink it.
Now figure out how many of your "tiles" would fit in a normal level. Once you have the number of tiles of the width and height of the level, multiply that by the tile size. For example, I'm creating a level editor for OldManClayton, and my tile size is 30x30. His real objects are 40x40 and the level dimensions are 800x600. The number of 30x30 tiles would fit 20 across and 14 down (assuming that the top is not part of the level, but the interface). This may seem confusing but it's not.
Okay, now create a quick backdrop and set it's width and height to the numbers you just previously came up with. Under properties, change the type to a Motif and edit the X sprite. In the animation editor, just use the rectangle tool and draw a square around the border of the tile. After clicking Okay, change the semi-transparency to around 80. Finally position it somewhere on the frame, but make sure to leave room for the buttons.
Make a button for each active object you have that will be created. You can either use an image or words to represent the object. Now, with many objects this might take awhile, but trust me, this is nothing compared to whats next.
Now create three counters and call them: "XPos, YPos, and Item Number". Put the X and Y Pos counters on the frame while the item number counter is hidden. Furthermore, put all the tiles in a qualifier called "group 1"
Events
Now I'm not going to outline all the events, but tell you how to set it up, because that would take forever!
Start of Frame:
-clear Array
Always:
-set counter "xpos" to (easy grid/position/get column from position/xmouse)
-set counter "ypos" to (easy grid/position/get row from position/ymouse)
-set X position of array to XPos
-set Y position of array to YPos
This will set each counter to the box that the mouse is in (note it starts at 0). To create objects first do whenever user presses the object button, set the "item number" counter to a number (that will correspond to that object through out this tutorial) You'll have to do that with each button...so it may take awhile.
Mouse is in zone (highlight grid):
Mouse is NOT over group 1:
User repeat clicks with left button:
Counter is equal to (#):
-Create (the object of the corresponding number) relative to the mouse (use an active that always is positioned at XMouse and YMouse)
-Snap the object to the grid (Easy Grid/Snap/ x position of object)
-write (number of object) at current array position
Do that for all the objects and again, it'll take awhile if you have tons of objects. Fortunately removing objects is easy! Just do:
Mouse is over Group 1:
User repeat clicks with right button:
-destroy group 1
-write 0 at current array position (zero is nothing)
That's the jist of how to make the level editor. Next tutorial will add the more advanced stuff and loading on the second frame. Here's the example file:
http://www.create-games.com/download.asp?id=7659
|
|
|