Here is the jsfiddle I've been working on: http://jsfiddle.net/TLYZS/
Upon debugging the code and inspecting the collision function, it's evident that the collision is functioning properly when the user overlaps with the other character. However, in a fighting game scenario, the collision should not work in this manner:
- It's noticeable that when I attempt to punch or kick the character from a slight distance, the collision detection function fails to register the impact even though it appears visually on the screen that the user is engaging with the character.
How can I adjust the collision detection function to enhance its accuracy?
function Collision(r1, r2) { return !(r1.x > r2.x + r2.w || r1.x + r1.w < r2.x || r1.y > r2.y + r2.h || r1.y + r1.h < r2.y); }