Get the full commented source code of

HTML5 Suika Watermelon Game

Talking about Flash and Game development.

Well, I don’t know if it’s really new or some of you already saw it elsewhere… but I’ve never seen this way to control the player

It works this way: you move the mouse pointer. When you click the mouse, the player will move in the opposite direction of your mouse pointer. The closer the pointer, the slower the movement.

It’s just a prototype, but remember that BallBalance was started from this prototype and ended with this sponsorship

_root.attachMovie("ball", "ball", _root.getNextHighestDepth(), {_x:250, _y:200});
_root.attachMovie("pnter", "pnter", _root.getNextHighestDepth(), {_x:250, _y:200});
moving = false;
Mouse.hide();
pnter.onEnterFrame = function() {
	this._x = _xmouse;
	this._y = _ymouse;
};
ball.onEnterFrame = function() {
	dist_x = this._x-_root._xmouse;
	dist_y = this._y-_root._ymouse;
	total_dist = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
	angle = Math.atan2(dist_y, dist_x);
	this.arrow._rotation = angle*57.2957795;
	if (moving) {
		dir = this.arrow._rotation;
		xspeed = total_dist/25*Math.cos(dir*0.0174532925);
		yspeed = total_dist/25*Math.sin(dir*0.0174532925);
	}
	this._x += xspeed;
	this._y += yspeed;
	xspeed *= 0.9;
	yspeed *= 0.9;
};
_root.onMouseDown = function() {
	moving = true;
};
_root.onMouseUp = function() {
	moving = false;
};

and the result is…

Download source code and make something decent.

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