I'm making a simple game. I have one stationary rectangle and one moving only on the y axis. It looks like this.
The right car is moving down. The two cars have a width of 40 and a height of 80.
When I check collision like this it doesn't work properly.
if (dist(other_car.x, other_car.y, main_car.pos.x, main_car.pos.y) < 40) {
console.log("colliding");
}
How do I make it more accurate?