summaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
authorAnthony Wang2024-01-30 00:33:18 +0000
committerAnthony Wang2024-04-13 04:32:17 +0000
commit423e7e389d70daa8be0f0844a58aa410d99bb2dc (patch)
tree7483ad4b2998d43d3b76e1405b82c71982f1f14c /script.js
parenta039dbbccde71bcfcd0278effc49cf98e0b4c28b (diff)
Add stress test file
Diffstat (limited to 'script.js')
-rw-r--r--script.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/script.js b/script.js
index 7946f62..3909b89 100644
--- a/script.js
+++ b/script.js
@@ -41,7 +41,7 @@ document.querySelectorAll("svg").forEach(function(svg) {
}
svg.querySelectorAll("path").forEach(function(path) {
// Get circles on path for collision checking
- let num = Math.floor(path.getTotalLength() / 5)
+ let num = Math.floor(path.getTotalLength() * 2 / rad)
for (let i = 0; i <= num; i++) {
const p = path.getPointAtLength(i / num * path.getTotalLength())
a.cm.x += p.x
@@ -113,10 +113,10 @@ function collide(a, b, c, n) {
// Collision of object a with wall at position k and direction d
function wallCollide(a, k, d) {
- if ((d == 0 && Math.abs(a.x - k) < a.r + rad) || (d == 1 && Math.abs(a.y - k) < a.r + rad)) {
+ if ((!d && Math.abs(a.x - k) < a.r + rad) || (d && Math.abs(a.y - k) < a.r + rad)) {
let c = {x: 0, y: 0, cnt: 0}
for (const p of a.p.map(x => rot(a, x))) {
- if ((d == 0 && Math.abs(p.x - k) < rad) || (d == 1 && Math.abs(p.y - k) < rad)) {
+ if ((!d && Math.abs(p.x - k) < rad) || (d && Math.abs(p.y - k) < rad)) {
c.x += p.x
c.y += p.y
c.cnt++