summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2024-01-30 03:14:33 +0000
committerAnthony Wang2024-04-13 04:32:17 +0000
commit6609d2a510f2712da91f4f0f877745f04519453d (patch)
treee39a8c12264d8d5d8ef905f0530ecaad90656cdd
parent423e7e389d70daa8be0f0844a58aa410d99bb2dc (diff)
Disable boop logging, attempt to fix glitching into walls
-rw-r--r--script.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/script.js b/script.js
index 3909b89..7fdc149 100644
--- a/script.js
+++ b/script.js
@@ -108,7 +108,7 @@ function collide(a, b, c, n) {
b.vx += n.x * j / b.m
b.vy += n.y * j / b.m
b.w += -cr(cb, n) * j / b.mi
- console.log('boop')
+ // console.log('boop')
}
// Collision of object a with wall at position k and direction d
@@ -182,6 +182,18 @@ function tick() {
a.x += a.vx
a.y += a.vy
a.th += a.w
+ // Don't allow glitching into walls
+ /* const px = a.p.map(x => rot(a, x).x)
+ let k = Math.min(...px) - rad
+ if (k < 0) a.x -= k
+ k = window.innerWidth - Math.max(...px) - rad
+ if (k < 0) a.x += k
+ const py = a.p.map(x => rot(a, x).y)
+ k = Math.min(...py) - rad
+ if (k < 0) a.y -= k
+ k = window.innerHeight - Math.max(...py) - rad
+ if (k < 0) a.y += k */
+ // Friction
if (Math.abs(a.vx) > 0.001) a.vx -= 0.001 * Math.sign(a.vx)
if (Math.abs(a.vy) > 0.001) a.vy -= 0.001 * Math.sign(a.vy)
if (Math.abs(a.w) > 0.00001) a.w -= 0.00001 * Math.sign(a.w)