From c012fec2870757990080e823d42dd91031e64f25 Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 6 Jul 2024 21:24:04 -0500 Subject: set rocket to relatively constant velocity --- levelSelect.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'levelSelect.js') diff --git a/levelSelect.js b/levelSelect.js index 2fe3d52..238639c 100644 --- a/levelSelect.js +++ b/levelSelect.js @@ -1,18 +1,37 @@ import{ setupLevel, setupLevelUi } from './level.js'; + +function buildLevel(x, y, t) { + const ts = t.slice(0, -1); + const tf = t[t.length-1]; + return setupLevel(ts.map(T => [ x(T), y(T) ]), [ x(tf), y(tf) ]); +} + const levels = { 'initial jump': [ [], setupLevel([], [8, 0]) ], 'monopole harvesting': [ ['initial jump'], setupLevel([[3, 3]], [8,8]) ], - 'parabolic': [ ['initial jump', 'monopole harvesting'], setupLevel([[-2, 4], [0,0], [2, 4]], [3,9]) ], + 'parabolic 0': [ ['initial jump', 'monopole harvesting'], setupLevel([[-2, 4], [0,0], [2, 4]], [3,9]) ], 'sinusoidal': [ ['initial jump', 'monopole harvesting'], - setupLevel([ - [-4, 4*Math.sin(0)], - [0.5*Math.PI - 4, 4*Math.sin(0.5*Math.PI)], - [1.0*Math.PI - 4, 4*Math.sin(1.0*Math.PI)], - [1.5*Math.PI - 4, 4*Math.sin(1.5*Math.PI)], - ], [2.0*Math.PI - 4, 4*Math.sin(2.0*Math.PI)]), + buildLevel(t => t-4, t => 4 * Math.sin(t), [...Array(8).keys()].map(x => Math.PI * x / 4)), + ], + 'parabolic 1': [ + ['parabolic 0'], + buildLevel(t => -0.5*(t-3)**2 + 4, t => t-3, [...Array(8).keys()].map(x => x - 2)), ], + 'orbital': [ + ['parabolic 0', 'sinusoidal'], + buildLevel(t => 8*Math.cos(t), t => 8*Math.sin(t), [...Array(8).keys()].map(x => Math.PI * x / 4)), + ], + 'lissajous 0': [ + ['orbital'], + buildLevel(t => 8*Math.cos(3*t), t => 8*Math.sin(2*t), [...Array(8).keys()].map(x => Math.PI * x / 4)), + ], + 'lissajous 1': [ + ['orbital'], + buildLevel(t => 8*Math.sin(4*t), t => 8*Math.cos(3*t), [...Array(16).keys()].map(x => Math.PI * x / 8)), + ], + }; export function setupLevelSelectUi(root, sfx) { -- cgit v1.2.1