/* --------------------------------------------------
Author: Anastasios Pallas / tcpallas@gmail.com
Version 1.0
Last Update: 2024-02-18
-------------------------------------------------- */


// Update stage will render next frame
createjs.Ticker.framerate = 15;
createjs.Ticker.addEventListener("tick", tickHandler);

function tickHandler(e) {
	stage.update();

	// light is getting smaller over time
	if (light.visible && light.scaleX > 0.3) {
		light.scaleX = light.scaleY = light.scaleY * 0.995;
		light.regX = light.regY = light.regY * 0.995;
		// scale dust also
		dust.scaleX = dust.scaleY = dust.scaleY * 0.995;
		dust.regX = dust.regX * 0.995;	// only on X, keep regY = 0 (top)
	}

	// leave scissor on the table
	if (config.current_step == 4) {
		if (scissor.x < config.center_x - 280) {
			scissor.x = scissor.x + 10;
		}
		if (scissor.x > config.center_x - 280)  {
			scissor.x = scissor.x - 10;
		}
		if (scissor.y < config.center_y + 165) {
			scissor.y = scissor.y + 10;
		}
		if (scissor.y > config.center_y + 165) {
			scissor.y = scissor.y - 10;
		}
	}
}
