2D collison detection and response in vanilla JavaScript
  • No mobile support as of yet. Move with WASD and shoot with Spacebar.
  • Move the red box. Red box collides with yellow, green and blue boxes.
  • Yellow box does not disappear when hit. This can simulate a barrier.
  • Blue and Green box disappear when hit. This can simulate targets.
  • Smaller violet boxes act as vertices for the polygon surrounding red box. Utilized a 2D raycasting algorithm to check bounds. Credit for raycasting algorithm
  • Notice red box and projectiles do not pass bounds of the polygon.
  • This collison detection and response algorithm was used in my jackal-js project.
  • View this code on my GitHub.