Limit velocity change from click, add position: fixed so this finally works on mobile

This commit is contained in:
Anthony Wang 2024-01-29 22:22:58 +00:00
parent ab39b82693
commit 389eeeb48d
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ
2 changed files with 2 additions and 1 deletions

View file

@ -202,7 +202,7 @@ function tick() {
// Use click to update velocities // Use click to update velocities
function updatev(event) { function updatev(event) {
for (a of A) { for (a of A) {
let d = ds(a, {x: event.clientX, y: event.clientY}) let d = Math.max(ds(a, {x: event.clientX, y: event.clientY}), 100)
a.vx += 100 * (a.x - event.clientX) / d a.vx += 100 * (a.x - event.clientX) / d
a.vy += 100 * (a.y - event.clientY) / d a.vy += 100 * (a.y - event.clientY) / d
} }

View file

@ -1,4 +1,5 @@
body { body {
position: fixed;
overflow: hidden; overflow: hidden;
touch-action: none; touch-action: none;
} }