Do you like my tutorials?

Then consider supporting me on Ko-fi

Talking about Bombuzal game, Flash, Game development and Users contributions.

It’s time to create the field of the first level.

Creating the level

Merging the ideas of Andre Marianiello and Chris, I was able to create the 2d level in this way:

// tiles array generation
tiles = [[0, 1, 0, 0], [1, 1, 2, 1], [1, 2, 1, 2], [0, 0, 1, 0]];
// bombs array generation
bombs = [[0, 1, 0, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 1, 0]];
// placing tiles
for (x=0; x

and this is the result:

Aligning the level to the stage

"Everything" is working, but I don't want the level to start at the upper left corner... I want the level to be centered in the stage.

So I have to calculate level's height and width and move the movieclip in the center of the stage.

// tiles array generation
tiles = [[0, 1, 0, 0], [1, 1, 2, 1], [1, 2, 1, 2], [0, 0, 1, 0]];
// bombs array generation
bombs = [[0, 1, 0, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 1, 0]];
// creating the level movieclip
_root.createEmptyMovieClip("level",_root.getNextHighestDepth());
// placing tiles
for (x=0; x

Now the level is aligned to the stage

Panning the level

I think advanced levels will be greater than this 4x4 array, so I have to allow the player to pan the level with mouse. I want the level to pan when the mouse gets closer to stage edges.

//tile size
tile_size = 50;
// pan variables
pan_dist = 50;
pan_speed = 5;
// tiles array generation
tiles = [[0, 1, 0, 0], [1, 1, 2, 1], [1, 2, 1, 2], [0, 0, 1, 0]];
// bombs array generation
bombs = [[0, 1, 0, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 1, 0]];
// creating the level movieclip
_root.createEmptyMovieClip("level",_root.getNextHighestDepth());
// placing tiles
for (x=0; xStage.width-pan_dist) {
		level._x -= pan_speed;
	}
	// pan down  
	if (_root._ymouseStage.height-pan_dist) {
		level._y -= pan_speed;
	}
};

And this is the first error... panning in this way means your level will pan even when your mouse is outside the stage. Probably you will need to reload the page to see the level in this movieclip

Also, I don't want the movieclip to leave the stage if it entirely fits in it.

That's where you can help me and have your name in the credits: make the level pan only when the mouse is inside the stage and don't let the level leave the stage if it entirely fits in it.

I would like you all to read AS3 Bombuzal tile test post in the forum by LivesInABox where you can find a very good AS3 script to generate both 2D and isometric levels.

It would be interesting to create Bombuzal both in AS2 and in AS3.

The winner of this post is LivesInABox for his wonderful AS3 work.

I remember that winners will have their names in the credits of this remake, and should the game be sponsored (but I think it will be quite hard because it's an open source game) I will share the income with winners.

Download the source code and fix that scrolling!

Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.