0

given is the x- and the y-coordinate of an image, and also it's height and width.

I now want to store every pixel of that image (ONLY THE LOCATION) in an array, so I can compare them to another array which also holds image-coordinates to check whether these images collide. How can I do that? I thought of an array, but even though I've also read a lot of explanation stuff about arrays, I don't get it.

Joey
  • 207
  • 4
  • 11

1 Answers1

1

I think what you really need is whether the 2 rectangles represented by the 2 images intersect.

For checking whether 2 rectangles intersect, see Math/ Algorithm/ JS: How to determine if 2+ rectangles intersect, given the TopLeft(x0, y0) and Bottom-Right(x1, y1) of each rectangle

Community
  • 1
  • 1
sray
  • 584
  • 3
  • 8