How To Make a Level Editor in MMF
  
    
    	
    	| 
        Author: |  steve 
         | 
        Submitted: |  4th September, 2003
         |  
        | 
        Views: |  7228
         | Rated: | 
        
        		
         |  
         
     | 
   
    
       
      
      
Wouldn't it be cool to make a custom built in level editor inside your game?  Other users can make their own levels and play it in the game, share it within a community, and do what nots.  Plus, you can easily churn out many levels with a level editor = 
 
 
I would suggest making a level editor for puzzle/arcade games, something that doesn't require scrolling.
 
 
Here is an example of my approach; it works flawlessly:
 
 
Objects used:
 
1. INI  - to store the data
 
2. File Object - for saving/loading
 
4. Active Object: "Blob" - a dummy object to work with
 
5. Counter "Count" - detects number of objects
 
 
Recommendation:
 
*Make a grid, it will be easy to place your objects on the screen.  Have it so that a Box will move relative to your Mouse cursor.  The box will move every 25 (for example) pixels- just like a "Snap To" in the Frame Editor.  Left clicking will create a Blob inside the Box.
 
 
*Building a Grid - you can find examples from Clickteam.  For simplicity, you can also use the EasyGrid object from Tigerworks.
 
 
Level Editor:
 
You built a grid (or not) and placed 5 blobs  on the screen.
 
 
Saving: 
 
 
1. Condition: Start of Frame:
 
Action: set INI file to: CurrentDirectory + "file".  Note: Current Directory is an action from the File Object.  This will save a file for the level.
 
 
2. Condition: Blob>0, Pick a Blob at Random:  
 
a) Set INI group to: str$(Count's Value) [note: this is a counter changed to a string, it starts off with 0, then 1,2,...]  
 
b) Set Item PosX=Blob's Xposition
 
c) Set Item PosY=Blob's YPosition
 
d) Destroy Blob
 
e) Count + 1
 
 
3. Condition: Blob=0
 
a) Set INI Group: str$(Count's Value)
 
b) Set Item "End" = 1
 
 
These three events will save your Blobs on the level, it will store their positions.
 
 
Loading:
 
 
set Count=0
 
 
1) Condition: INI Group: str$(Count's Value) Item "End" is not 1
 
a) Create a Blob at (-100,-100) (hide it)
 
b) Set BlobXPosition= Item "XPos"
 
c) ..same for Y position
 
d) Count ++
 
 
 
This is a simplified version for a level editor, but there are a lot more that can be done with it.  
 
 
I'm currently developing Ballmaster2, it has a level editor that keeps track of over 10 different objects, build objects in order (ie: background first), store special conditions, and can be chained together to fit into a World (20 consecutive levels)
 
 
Hope this helps!
 
 |  
  
 
	
	 
	
	 
	
	
		
		
  
	
	
 | 
 
 
	 |