Get the full commented source code of

HTML5 Suika Watermelon Game

Talking about Stringy game, Actionscript 3, Flash and Game development.

Do you remember my Flash game called Stringy?

I blogged about it about a month ago and some people asked me some hints about the way used to catch the stars drawing a lasso around it.

There are a lot of mathematical formulas to solve this task, and range from “more than complicate” to “you must be joking”.

I decided to post a prototype of the code I used starting from the post Develop a Flash game like String Avoider – AS3 version – and more!, without any comment, and it will be up to you to guess how I solved the problem in a ridiculously easy way.

This is what you will get:

Catch the circle with a lasso to make it move in a random spot.

And this is the code:

package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	public class Main extends Sprite {
		private var tailLenght:Number=1;
		private var tailNodes:Number=300;
		private var tailCanvas:Sprite=new Sprite();
		private var areaCanvas:Sprite=new Sprite();
		private var targetCanvas:Sprite=new Sprite();
		private var nodes:Vector.=new Vector.();
		private var target:Point;
		public function Main() {
			for (var i:int=0; i=new Vector.();
			tailCanvas.graphics.clear();
			tailCanvas.graphics.lineStyle(3,0x00ff00);
			tailCanvas.graphics.moveTo(mouseX,mouseY);
			areaCanvas.graphics.clear();
			nodes[0]=new Point(mouseX,mouseY);
			sampleNodes[0]=new Point(mouseX,mouseY);
			for (var i:int=1; isegment1Len) {
				return null;
			}
			if (Math.pow(p2.x-px,2)+Math.pow(p2.y-py,2)>segment1Len) {
				return null;
			}
			if (Math.pow(p3.x-px,2)+Math.pow(p3.y-py,2)>segment2Len) {
				return null;
			}
			if (Math.pow(p4.x-px,2)+Math.pow(p4.y-py,2)>segment2Len) {
				return null;
			}
			return new Point(px,py);
		}
	}
}

No need to download anything, you can replace the code contained in the original prototype with this one.

Did you figure out how I made it possible with no formulas?

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