Skip to content

Optimize collision detection #4

Description

@SIY1121

Optimize collision detection using algorithm such as Quaternary Spatial Partitioning.

// TODO reduce the computational cost
let remainingContributions = 0
this.blocks
.filter((b) => b.life > 0)
.forEach((b) => {
const d = intersectDirection(this.ball, b)
// the ball hit the block
if (d !== Direction.None) {
this.ball.onCollide(d)
b.onCollide()
this.score += b.origianlLife
}
remainingContributions += b.life
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions