//===============================================//
// Swimming //
// by Melinne Hay //
//===============================================//
//declairing the variables
float fishPositionX =100;
float fishPositionY = 185;
float otherFishPositionX, otherFishPositionY;
//this is setting up everything inculding frame rate, size of the program and the backround colour
void setup() {
color(#9DCCDE);
size(400, 400);
rectMode(CENTER);
ellipseMode(CENTER);
}
void draw()
{
updateOtherFishPosition();
drawWater();
drawOtherFishes();
drawClearWater();
drawLeaves();
drawFish();
}
void drawFish() {
//this is the function to draw the fish and it's fin and eye
noStroke();
fill(#CB1B1B);
//mouseY moves the fish
ellipse(fishPositionX, mouseY+fishPositionY, 90, 60);
triangle(10, mouseY+150, 10, mouseY+220, 100, mouseY+180);
fill(0);
ellipse(125, mouseY+185, 5, 5);
}
void updateOtherFishPosition()
{
//move from left to right
otherFishPositionX--;
//when off screen picks random spot within restraint to draw the fish
if (otherFishPositionX<-200)
{
otherFishPositionX=width+150;
otherFishPositionY=random(0, 250);
}
}
//this is drawing the leafs at the bottom of the screen
void drawLeaves() {
int x;
x =0;
while ( x < 400) {
noStroke();
fill(#25B219);
ellipse(10+x, 380, 40, 60);
ellipse(45+x, 390, 40, 40);
x= x + 60;
}
}
void drawWater() {
//drawing backround color with a greenish tint
fill(#6BDECF);
rect(200, 200, 400, 400);
}
void drawClearWater() {
//this draws the blue overlay
fill(#6BB6DE, 150);
rect(200, 200, 400, 400);
}
void drawOtherFishes()
{
// this function draws the other fish that spawns in the backround
noStroke();
fill(#CB1B1B);
ellipse(otherFishPositionX+100, otherFishPositionY+fishPositionY, 90, 60);
triangle(otherFishPositionX+200, otherFishPositionY+150, otherFishPositionX+200, otherFishPositionY+220, otherFishPositionX+100,
otherFishPositionY+ 180);
fill(0);
ellipse(otherFishPositionX+80, otherFishPositionY+185, 5, 5);
}