JS if x through another position

I'm trying to make a snake game and did everything exept walls. A solution I had was to load an image and do a collision. It worked except it only checked for certain position not a x position through another position see the gif bellow:

My Code:

You are viewing a single comment. View All

Yeah, it's because the rectangle is centered, just add 8 to the x and y of the snake to account for the width.

Does that make sense?


@Coder100 Nope. Where do I add it?