Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Beginner Array Question

$
0
0

I have an array of narrow vertical rectangles. Each rectangle moves randomly back and forth (left to right) across the screen.

When *any of these overlap I want an event to happen, eg. println "overlapping". So far this works fine with 2 rectangles, but only by referring directly to their number and not array indices.

Screen Shot 2018-02-16 at 21.21.04

When I try indexing, I am running into the issue that, when a rectangle is checking if it overlaps another, it is also checking if it overlaps itself, and thus always returns "overlapping". I get what is happening but how to solve it is a little beyond my reasoning abilities.

Would anyone care to offer some tips? Many thanks.


Viewing all articles
Browse latest Browse all 2896

Trending Articles