Disable boop logging, attempt to fix glitching into walls
This commit is contained in:
parent
423e7e389d
commit
6609d2a510
14
script.js
14
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)
|
||||
|
|
Loading…
Reference in a new issue