I am still struggling to have my vectors read the background image. I want my ellipses to change directions when they reach a black obstacle on the background image. At the moment I am using:
void avoid() {
for (int i = 0; i < ballCollection.size(); i++) {
color locationColour = get (int(loc.x), int(loc.y));
if (locationColour != -1) { //if locationColour is not equal to white
I have written a code using 2D vectors where ellipses are flocking and being attracted to a mouse press. I have loaded in an 2 bit gif (black and white image) and want to use it as an obstacle map. I was able to do this when i wasn't using vectors with the code:
color locationColour = get (x, y);
if (locationColour == -16777216) {
// If the object reaches a black pixel, multiply speed by -1 to turn it around.
speedX = speedX * -1;
speedY = speedY * -1;
}
but now that I am using vectors I get an error message:
"The method get(int,int) in the type PApplet is not applicable for the arguments (float,float)"
is there any way to get(float,float) or similar?