Get the full commented source code of

HTML5 Suika Watermelon Game

Talking about Platform game game, Actionscript 2, Flash and Game development.

I am about to develop a tile based platform engine that (in my opinion) will allow to create a lot of different games just changing some parameters.

At the moment it only allows to move horizontally but everything is planned, from rooms to jumps, ladders and ropes.

My goal is making the developer only focus on level design.

The most interesting thing is I am developing both AS2 and AS3 versions of the engine.

The other platform engine I created some time ago is discontinued. This will be better.

In this first part, we have four tile types:

Ground: the normal ground, with a normal acceleration and friction

Ice: a slippery tire, with reduced acceleration and friction

Left and right treadmills: these tiles will increase/decrease your speed according to their arrow

tile_size = 20;
ground_acceleration = 1;
ground_friction = 0.8;
ice_acceleration = 0.15;
ice_friction = 0.95;
treadmill_speed = 2;
max_speed = 3;
xspeed = 0;
level = new Array();
level[0] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
level[1] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
level[2] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
level[3] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
level[4] = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 1, 1, 4, 4, 4, 4, 1, 1];
player = [1, 3];
function create_level(l) {
	_root.createEmptyMovieClip("level_container", 1);
	level_height = l.length;
	level_width = l[0].length;
	for (y=0; ymax_speed) {
		xspeed = max_speed;
	}
	if (xspeed<-max_speed) {
		xspeed = -max_speed;
	}
	xspeed += bonus_speed;
	x_pos += xspeed;
	level_container.hero._x = x_pos;
	xspeed -= bonus_speed;
};
function ground_under_feet() {
	bonus_speed = 0;
	y_feet = Math.floor(y_pos/tile_size)+1;
	x_feet = Math.floor((x_pos+tile_size/2)/tile_size);
	switch (level[y_feet][x_feet]) {
	case 1 :
		over = "ground";
		speed = ground_acceleration;
		friction = ground_friction;
		break;
	case 2 :
		over = "ice";
		speed = ice_acceleration;
		friction = ice_friction;
		break;
	case 3 :
		over = "treadmill";
		speed = ground_acceleration;
		friction = ground_friction;
		bonus_speed = -treadmill_speed;
		break;
	case 4 :
		over = "treadmill";
		speed = ground_acceleration;
		friction = ground_friction;
		bonus_speed = treadmill_speed;
		break;
	}
}

Move the player with arrows keys, more information to come during next days...

Download the source code and enjoy...

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