Gaming Your Way

May contain nuts.

Friends and foes

For anyone who's interrested: it's shit weather outside. And cold. And grey. And it rains.

So Nuts and Bolts getting near gold status every minute I thought I might explain how lazy I was this time with the level editor. So lazy in fact, that there is no such thing. As Nuts and Bolts is a puzzle game and is using a fairly simple map structure I thought I could get away with doing the maps in the Flash IDE.

The basic idea was to place Movieclips on a grid and read out the names and positions at runtime.

Here's a screenshot of the first level:

The squares and circles are in the background so that I know where to align my Movieclips, you can see the textboxes which provide addtional informations for the parsing routine (name is not used in the game anymore, but I was to lazy to remove it and the last box contains the help screens that should be displayed).

Each of the level elements got a name I use to build the map, so the yellow circles with the white "p" are normal platforms (name:"pl"), the green "e" is the exit and so on. Luckily we can use the same name more than once in as3 so I could just copy and paste elements once I had decided what name they should use...

Here's another screenshot of a later level:

All we have to do now is to get a copy of the Movieclip (the level MCs are exported for runtime use) with this:

private function getLevelMC (iLevel:int):MovieClip {
	var myClass:Class = getDefinitionByName("mcLevel_" + iLevel.toString()) as Class;
	var mcReturn:MovieClip = new myClass() as MovieClip;
	return mcReturn;

And the run the parser of that MC (just a part of the code, though):

// find platforms 
for (i = 0; i < mcMapTemplate.numChildren; i++) {          
	mcLevel = mcMapTemplate.getChildAt(i) as MovieClip;          
	bVisible = false;     
	x = Math.floor(mcLevel.x / 60);     
	y = Math.floor(mcLevel.y / 60);          
	switch ( {         
		case "pl": // normal platform             
			this._aMap[x][y].p = PLATFORM_NUTS;             
			bVisible = true;             
		case "start":         
		case "start_0":         
		case "start_1":        
		case "start_2":         
		case "start_3":             
			this._aMap[x][y].p = PLATFORM_START; // we'll set the dir later when adding beam's data             
			this._aMap[x][y].d = 0; 
			this._pCurrent = new Point(x, y);
			this._pNuts = new Point(x, y);                          
			if (StrUtil.contains(, "_")) {                 
				this._aMap[x][y].d = StrUtil.cInt(StrUtil.part(, "_", 1));             
			bVisible = true;             
		// [Skipped a lot of code ...]     

Then the Movieclip can be removed again and I can plot the level from the resulting map data array ...

For this game this was hazzle free way of doing (and changing) the 30 levels.

And with that, I'm getting back to the game, I have some sounds to add before it becomes gold ...


Comments (1) -

  • FlashMush

    7/14/2011 5:32:42 PM |

    This game looks like it's coming out well, can't wait!

Comments are closed