Skip to content

Commit

Permalink
Merge branch 'limit-missile'
Browse files Browse the repository at this point in the history
  • Loading branch information
okwme committed Aug 12, 2024
2 parents a5dbd30 + e737446 commit ebfd9ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/index.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/anybody.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,21 @@ export class Anybody extends EventEmitter {
}
// b.velocity.setMag(this.missileSpeed * this.speedFactor)
b.velocity.limit(this.missileSpeed * this.speedFactor)
let sum = b.velocity.x - b.velocity.y
const max = this.missileVectorLimitSum / 1000
if (sum > max) {
b.velocity.limit(this.missileSpeed * this.speedFactor * 0.999)
console.error({
x: b.velocity.x,
y: b.velocity.y,
max: this.missileVectorLimitSum / 1000
})
sum = b.velocity.x - b.velocity.y
if (sum > max) {
console.error('still too fast')
return
}
}
// const bodyCount = this.bodies.filter((b) => b.radius !== 0).length - 1
// this.missiles = this.missiles.slice(0, bodyCount)
// this.missiles = this.missiles.slice(-bodyCount)
Expand Down

0 comments on commit ebfd9ce

Please sign in to comment.