Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

box collision detection

function colidedWithRect(rect: Rectangle) {

  if (this.position.x + this.width > rect.position.x &&
      this.position.x < rect.position.x + rect.width &&
      this.position.y + this.width > rect.position.y &&
      this.position.y < rect.position.y + rect.height) {
    return true
  }

  return false
}
 
PREVIOUS NEXT
Tagged: #box #collision #detection
ADD COMMENT
Topic
Name
6+2 =