Disable boop logging, attempt to fix glitching into walls

This commit is contained in:
Anthony Wang 2024-01-30 03:14:33 +00:00
parent 423e7e389d
commit 6609d2a510
Signed by: a
SSH key fingerprint: SHA256:B5ADfMCqd2M7d/jtXDoihAV/yfXOAbWWri9+GdCN4hQ

View file

@ -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)