TheKrunch / arbitPong

A pong game with an arbitrary amount of players, over the internet! Using this to learn JavaScript and web development.
https://thekrunch.github.io/arbitPong/
2 stars 1 forks source link

ballCornerIntersect() function contains redundant code #1

Open TJScalzo opened 3 years ago

TJScalzo commented 3 years ago

Three quarters of this function are repeated lines of code. It could be more efficient if it applied the logic to each point in the rectangle automatically. This would also, in theory, allow you to check if a ball is intersecting with a corner of a polygon with an arbitrary number of sides rather than just the hard-coded rectangle. https://github.com/TheKrunch/arbitPong/blob/7a22115216c361f383d02d7ecbda2ce48545d97c/scripts.js#L189-L235