{"id":15828618,"url":"https://github.com/jesselpalmer/collision-detect","last_synced_at":"2025-04-01T18:31:08.932Z","repository":{"id":2947305,"uuid":"3960701","full_name":"jesselpalmer/collision-detect","owner":"jesselpalmer","description":"Simple 2D JavaScript collision detection library","archived":false,"fork":false,"pushed_at":"2024-02-11T16:38:01.000Z","size":931,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-06T10:41:32.807Z","etag":null,"topics":["2d-collision","2d-collision-library","collision","collision-detection","collisions","game-library","graphics-library","rectangle-collisions","square-collisions"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rocker-org/shiny","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jesselpalmer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jesselpalmer"}},"created_at":"2012-04-07T21:23:13.000Z","updated_at":"2023-08-28T00:36:00.000Z","dependencies_parsed_at":"2024-10-26T15:59:47.315Z","dependency_job_id":null,"html_url":"https://github.com/jesselpalmer/collision-detect","commit_stats":null,"previous_names":["jesselpalmer/collisiondetect"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesselpalmer%2Fcollision-detect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesselpalmer%2Fcollision-detect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesselpalmer%2Fcollision-detect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jesselpalmer%2Fcollision-detect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jesselpalmer","download_url":"https://codeload.github.com/jesselpalmer/collision-detect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246635983,"owners_count":20809333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d-collision","2d-collision-library","collision","collision-detection","collisions","game-library","graphics-library","rectangle-collisions","square-collisions"],"created_at":"2024-10-05T10:41:38.082Z","updated_at":"2025-04-01T18:31:08.692Z","avatar_url":"https://github.com/jesselpalmer.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jesselpalmer"],"categories":[],"sub_categories":[],"readme":"[![npm](https://img.shields.io/npm/dw/collision-detect.svg)](https://www.npmjs.com/package/collision-detect) [![Node.js CI](https://github.com/jesselpalmer/collision-detect/actions/workflows/nodejs-ci.yml/badge.svg)](https://github.com/jesselpalmer/collision-detect/actions/workflows/nodejs-ci.yml/)\n\n# Collision Detect\n\nCollision Detect is a JavaScript library designed specifically for collision\ndetection. Happy colliding!\n\n## Installation\n\nTo install Collision Detect using npm:\n\n```bash\nnpm install collision-detect --save\n```\n\nThen, in your JavaScript file:\n\n```javascript\nimport {isCollidingWith} from 'collision-detect';\n```\n\nNote: Ensure you have Node.js and npm installed on your machine before\nattempting the installation.\n\n## Usage\n\nAt present, the library supports collision detection for squares and rectangles.\n\nTo leverage the library, it's required for objects to have the properties:\n`x1`, `x2`, `y1`, and `y2`. Though they can have other properties or methods,\nthese are required for the collision detection to work.\n\n### Simple object example\n\n```javascript\nimport {isCollidingWith} from 'collision-detect';\n\nlet obj1 = {\n  x1: 0,\n  x2: 10,\n  y1: 0,\n  y2: 10,\n};\n\nlet obj2 = {\n  x1: 5,\n  x2: 15,\n  y1: 5,\n  y2: 15,\n};\n\nif (isCollidingWith(obj1, obj2)) {\n  // collision detected!\n  obj1.x1 += 1;\n  obj1.x2 += 1;\n}\n```\n\n### Slightly more complex example\n\n```javascript\nimport {isCollidingWith} from 'collision-detect';\n\nclass Rectangle {\n  constructor(x1, x2, y1, y2) {\n    this.x1 = x1;\n    this.x2 = x2;\n    this.y1 = y1;\n    this.y2 = y2;\n  }\n\n  moveRight() {\n    this.x1++;\n    this.x2++;\n  }\n}\n\nclass Square extends Rectangle {\n  constructor(...args) {\n    super(...args);\n  }\n}\n\nconst rectangle = new Rectangle(5, 15, 5, 15);\nconst square = new Square(0, 10, 0, 10);\n\nif (isCollidingWith(square, rectangle)) {\n  // collision detected!\n  square.moveRight();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesselpalmer%2Fcollision-detect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjesselpalmer%2Fcollision-detect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjesselpalmer%2Fcollision-detect/lists"}