Projectile Path Projection

This is just a little something that I was thinking about. It’s a very small script, but may help someone who is wanting to achieve such an effect. Enjoy :thumb:

Stage.align = "TL"; Stage.scaleMode = "noScale"; _quality = "medium";

var startX:Number = 0; var startY:Number = 0;
var mouseIsDown:Boolean = false; var gravity:Number = 20;

_root.onMouseDown = function() { startX = _xmouse; startY = _ymouse; mouseIsDown = true; }
_root.onMouseUp = function() { mouseIsDown = false; }

_root.onEnterFrame = function() {
	_root.clear(); if (!mouseIsDown) { return; } _root.lineStyle(1, 0xCCCCCC, 100); _root.moveTo(startX, startY);
	
	var hVel:Number = _xmouse-startX; var vVel:Number = _ymouse-startY;
	var t:Number = 0; var x:Number = startX; var y:Number = startY;
	var draw:Boolean = true;
	
	while (y < Stage.height) {
		t+=0.1; //how detailed the line is. 0 = infinitely detailed (don't use this, obv)
		x = startX + hVel*t; y = startY + vVel*t + 0.5*gravity*t*t;
		if (draw=!draw) { _root.lineTo(x, y); } else { _root.moveTo(x, y); }
	}
}