Skip to content

Commit

Permalink
feat: improve/Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Mar 1, 2024
1 parent 40ee7e3 commit d41c1fa
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,11 @@ Depending on your use case:
Check collisions for all bodies or a single body:

```ts
// all bodies
const collided = system.checkAll((response: Response) => {
// if you want to end after first collision
return true
})
// check if any body collides, end after first collision and return true
const collided = system.checkAll(() => true)

// check for one `body`
const collided = system.checkOne(body, (response: Response) => {
// if you want to end after first collision
return true
})
// check if 1 body collides, end after first collision and return true
const collided = system.checkOne(body, () => true)
```

For a direct collision check without broad-phase search, use `system.checkCollision(body1, body2)`. However, this isn't recommended due to efficiency loss.
Expand Down Expand Up @@ -228,10 +222,7 @@ const testCollision = ({ x, y }, radius = 10) => {
// create and add to tree
const circle = system.createCircle({ x, y }, radius)
// init as false
const collided = system.checkOne(circle, () => {
// ends iterating after first collision
return true
})
const collided = system.checkOne(circle, () => true)

// remove from tree
system.remove(circle)
Expand Down

0 comments on commit d41c1fa

Please sign in to comment.