Me and this guy, pretty cool number tutor. Funny man, always happy even when I always get answers wrong and seem to watch YouTube during class
Oh yeah and my parents, for giving him money
When you draw line, computer find the linear equation version of line. Computer play "pretend you're in the middle of the universe" and draw a perpidicular line that crosses your mouse point. Then grabs the intersection point of the perpindicylar line and see if the point is close to your circle mouse to bump.
No living human would actually want to know and read through all this, but I like explaining things and put some meaningful comments in my github commit.
Uh, so I don't actually need to "simulate" two perpindicular lines, that's just the concept of how a human would do it.
For the computer, I just throw in an equation to immediately get the dot, whose equation is built upon the concept
Here equation for finding, imma gonna call him Billy:
I'm using this linear equation: y = mx + k
Before I got anywhere close to making the above, I was Google searching "How to solve two linear equations in Javascript" and almost made a Stack Overflow question, which I clearly doubted doing because it seemed more like a math problem and might lose me some reputation.
Anyways, back to how computer do it, it substracts the coordinates of the two points, that make up the line, by the coordinates of the mouse (X - MouseX, Y - MouseY). So relatively, where the mouse used to be is now located in the middle.
Then I use the new cooridnates and shoot Billy at it and grabs the intersection point's coordinates. Yes I knoe the image above is ahead of me.
All there's left to do is to grab the sum of the point's coordinates and the mouse's, which I then decided to visually show it when you click the "Debug: Off" (Or "Debug: On", if you already turned it on);
And nail Pythagoras to get the distance from the point to the mouse to see if it's close enough to be colliding.
The end
Assuming you know how to get m and k, but they teach you that in 6-7th grade
EYO ID FREAKING DID IT
I can color red lines
Expanded on the Descriptoon
Made the link work
Debug button work
I'm done
Oh yeah, and also slightly increased the radius of the circle, because it visually looked like it was colliding too late
EYO ID FREAKING DID IT
But I can't color red lines
Expanded on the Descriptoon
It was a struggle of laziness
tyleing ndone
You can draw lines
Intersection point sorta working
I have no idea what I'm doing wrong
Reset button working, Debug no.
Initial commit
Can't properly size canvas
At least I got the style of the sdiscirption right, sort of