Get the full commented source code of

HTML5 Suika Watermelon Game

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

This 5th step is kinldy produced by Frederik J, who decided to upgrade the game with some new features

Recently I was looking in some old posts on your site, and saw the bombuzal step 4.

It hasn’t been finished, and because I think it wasn’t a hard task i took it!

Here it is, finished – now you can drop and pickup bombs, and you can also explode them if space is down for more than two seconds.

This comes before my main upgrade that will allow to play a complete level, and it has comments in the code for your understanding

//create an invisible movie clip across the entire stage using API
_root.createEmptyMovieClip("base", 1);
with (base) {
	lineStyle(2, 0x0000000, 0);
	beginFill(0x00000000, 0);
	lineTo(Stage.width, 0);
	lineTo(Stage.width, Stage.height);
	lineTo(0, Stage.height);
	lineTo(0, 0);
}
//whether to pan or not
level_pan = false;
//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, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 1]];
// main sprite
// xpos: bombuzal x position
// ypos: y position
// moving: bombuzal is moving or not
// facing: the side bombuzal is facing on
bombuzal_obj = {xpos:0, ypos:1, moving:false, facing:"right"};
//space down variable for checking if space is down for more
//than two seconds
space_down = false;
//time variable for checking how long space has been down
space_time = 0;
// bombuzal walk speed, in pixels/frame
walk_speed = 5;
// time passed since bombuzal last move
does_not_move = 0;
// creating the level movieclip
_root.createEmptyMovieClip("level", _root.getNextHighestDepth());
// placing tiles
for (x=0; x=60) {
			//then explode bombs
			explode_bombs();
		}
	}
};
// centering level
level._x = (Stage.width-tiles.length*tile_size)/2;
level._y = (Stage.height-tiles[0].length*tile_size)/2;
level.onEnterFrame = function() {
	//if mouse is on stage
	if (level_pan) {
		//stopping level leaving screen
		//too high
		if (level._y<=0) {
			level._y = 0;
		}
		//too low                                      
		if (level._y>=Stage.height-level._height) {
			level._y = Stage.height-level._height;
		}
		//too far to the left                                      
		if (level._x<=0) {
			level._x = 0;
		}
		//too far to the right                                      
		if (level._x>=Stage.width-level._width) {
			level._x = Stage.width-level._width;
		}
		// panning level                                      
		// pan right
		if (_root._xmouseStage.width-pan_dist) {
			level._x -= pan_speed;
		}
		// pan down                                      
		if (_root._ymouseStage.height-pan_dist) {
			level._y -= pan_speed;
		}
	}
};
//when mouse is on stage pan
base.onRollOver = function() {
	level_pan = true;
};
//when mouse leaves stage stop panning
base.onRollOut = function() {
	level_pan = false;
};
//function that handles bombs
function handle_bombs() {
	//if theres a bomb on the tile
	if (bombs[bombuzal_obj.ypos][bombuzal_obj.xpos] == 1) {
		//pickup bomb
		//remove the bomb
		_root.level["bomb"+bombuzal_obj.xpos+"_"+bombuzal_obj.ypos].removeMovieClip();
		//set the bomb array[y][x] to 0
		bombs[bombuzal_obj.ypos][bombuzal_obj.xpos] = 0;
	} else {
		//place bomb
		placed = _root.level.attachMovie("bomb", "bomb"+bombuzal_obj.xpos+"_"+bombuzal_obj.ypos, _root.level.getNextHighestDepth());
		placed._x = bombuzal_obj.xpos*tile_size;
		placed._y = bombuzal_obj.ypos*tile_size;
		//add to bomb array
		bombs[bombuzal_obj.ypos][bombuzal_obj.xpos] = 1;
	}
}
function explode_bombs() {
	//loop through bomb array
	for (x=0; x

And here it is:

Download the source and say thanks to Frederik

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