Solve this entire Processing exercise with no aditional comments or explanations, simply…
- User
Solve this entire Processing exercise with no aditional comments or explanations, simply give me the altered code already perfectly solved: {class Fish { PImage fishImage; int sizeFish; float speed; int scaleX; boolean isAlive;
float x; float y;
Fish(float x_, float y_, PImage img) x = x_; y = y_; fishImage = img.copy(); sizeFish = (int)random(25, 100); fishImage.resize(sizeFish, 0); speed = 100.0/sizeFish; scaleX = 1; isAlive = true;
void drawFish() { if (isAlive) pushMatrix(); translate(sizeFish/2, 0); scale(scaleX, 1.0); translate(-sizeFish/2, 0); imageMode(CORNER); image(fishImage, x*scaleX, y); popMatrix();
}
void moveFish() { if (isAlive) { x += speed; if (x < 0 || x > width - fishImage.width) speed = -speed; x += speed; scaleX = -scaleX; y += fishImage.height;
code}}
boolean checkDistance(int predatorX, int predatorY) { boolean isNearby = false;
codeif (isAlive && dist(predatorX-100, predatorY, x+sizeFish/2, y) < 250 && abs((predatorX-100) - (x+sizeFish/2)) < abs(speed)) isAlive = false; isNearby = true; return isNearby;}
void reset() { if (!isAlive) isAlive = true; y = (int)random(100, 500);
} }}
- Assistantjava
class Fish { PImage fishImage; int sizeFish; float speed; int scaleX; boolean isAlive; float x; float y; Fish(float x_, float y_, PImage img) { x = x_; y = y_; fishImage = img.copy(); sizeFish = (int)random(25, 100); fishImage.resize(sizeFish, 0); speed = 100.0/sizeFish; scaleX = 1; isAlive = true; } void drawFish() { if (isAlive) { pushMatrix(); translate(sizeFish/2, 0); scale(scaleX, 1.0); translate(-sizeFish/2, 0); imageMode(CORNER); image(fishImage, x*scaleX, y); popMatrix(); } } void moveFish() { if (isAlive) { x += speed; if (x < 0 || x > width - fishImage.width) { speed = -speed; x += speed; scaleX = -scaleX; y += fishImage.height; } } } boolean checkDistance(int predatorX, int predatorY) { boolean isNearby = false; if (isAlive && dist(predatorX-100, predatorY, x+sizeFish/2, y) < 250 && abs((predatorX-100) - (x+sizeFish/2)) < abs(speed)) { isAlive = false; isNearby = true; } return isNearby; } void reset() { if (!isAlive) { isAlive = true; y = (int)random(100, 500); } } }