I have a simple p5.js code and I need add collision using matter.js. One of the options is to draw rectangles instead of lines and then hang the necessary component on them, but I don’t know how to rotate and place these rectangles correctly in order to get the correct line from them later.
Thanks!
let lines = [];
function setup() { 
  createCanvas(400, 400);
  } 
function draw() { 
  background(255);
  strokeWeight(0);
  strokeWeight(2);
  if(mouseIsPressed)
  {
      line(mouseX,mouseY,pmouseX,pmouseY) 
      lines.push(mouseX,mouseY,pmouseX,pmouseY);
  }
  for(let i=0;i<lines.length;i+=4)
  {
    line(lines[i],lines[i+1],lines[i+2],lines[i+3]) 
  }
    
  
}