Script: Geometric Jumps - Poyo-SSB/osu-playground GitHub Wiki

function start() {
	var center = Playground.AddVector2('center', new Vector2(Playground.PLAYFIELD_WIDTH / 2, Playground.PLAYFIELD_HEIGHT / 2));
	var startRadius = Playground.AddFloat('startRadius', 0);
	var endRadius = Playground.AddFloat('endRadius', 100);
	var startRotation = Playground.AddFloat('startRotation', 180);
	var endRotation = Playground.AddFloat('endRotation', 180);
	var repetitions = Playground.AddInt('repetitions', 8);
	var ngon = Playground.AddInt('ngon', 2);

	Playground.AddOptionVector2(center, 'Center');
	Playground.AddOptionFloat(startRadius, 'Start radius', 0, 0, 200);
	Playground.AddOptionFloat(endRadius, 'End radius', 0, 0, 200);
	Playground.AddOptionFloat(startRotation, 'Start rotation', 1, 0, 360);
	Playground.AddOptionFloat(endRotation, 'End rotation', 1, 0, 360);
	Playground.AddOptionInt(repetitions, 'Repetitions', 2, 24);
	Playground.AddOptionInt(ngon, 'N-gon', 2, 10);
}

function update() {
	var center = Playground.GetValueVector2('center');
	var startRadius = Playground.GetValueFloat('startRadius');
	var endRadius = Playground.GetValueFloat('endRadius');
	var startRotation = Playground.GetValueFloat('startRotation');
	var endRotation = Playground.GetValueFloat('endRotation');
	var repetitions = Playground.GetValueInt('repetitions');
	var ngon = Playground.GetValueInt('ngon');

	for (var i = 0; i < repetitions; i++) {
		var t = i / (repetitions - 1);
		var radius = Math.lerp(startRadius, endRadius, t);
		var rotation = Math.lerp(startRotation, endRotation, t);

		var offset = rotation / 180 * Math.PI;

		var basePosition = add(center, new Vector2(0, radius));

		for (var j = 0; j < ngon; j++) {
			Playground.AddHitCircle(rotate(basePosition, center, offset + j * 2 * Math.PI / ngon));
		}
	}
}