I am looking for a way to prevent two rectangles from entering each other in the html canvas and I cannot find a solution. I mean that as soon as the collision between the edges of the rectangles within the canvas has taken place they cannot overlap, however I hope I have explained myself better. Thank you in advance for your help, I've searched here on stackoverflow but haven't found anything that really helps me!