Skip to content

Instantly share code, notes, and snippets.

@maydemir
Created November 9, 2014 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maydemir/2493bed879f96b1b53a5 to your computer and use it in GitHub Desktop.
Save maydemir/2493bed879f96b1b53a5 to your computer and use it in GitHub Desktop.
First Water and sky code
PImage sea2;
PImage sky1;
PImage fish;
PImage birds;
float x;
float y1;
float y2;
ArrayList<PImage> fishImg;
ArrayList<PImage> birdImg;
float position1[][];
float position2[][];
int count1;
int count2;
void setup()
{
size(800, 520);
fish = loadImage("fish.png");
birds = loadImage("bird.png");
sea2 = loadImage("sea2.png");
sky1 = loadImage("sky1.png");
fishImg = new ArrayList<PImage>();
birdImg = new ArrayList<PImage>();
position1 = new float[200][2];
position2 = new float[200][2];
smooth();
//y1 = random(0, height/2);
//y2 = random(height/2, height);
}
void draw()
{
background(0);
image(sky1, 0, 0);
image(sea2, 0, height/2);
for (int x = 0; x < fishImg.size (); x++)
{
image(fishImg.get(x), position2[x][0], position2[x][1]);
position2[x][0] = position2[x][0] + 1;
}
for (int x = 0; x < birdImg.size (); x++)
{
image(birdImg.get(x), position1[x][0], position1[x][1]);
position1[x][0] = position1[x][0] + 1;
}
}
void mousePressed()
{
//birdImg.add(new bird);
x = mouseX;
y1 = mouseY;
y2 = mouseY;
if (mouseY <= (height / 2 - 50))
{
birdImg.add(count1, birds);
position1[count1][0] = x;
position1[count1][1] = y1;
count1++;
}
if (mouseY > height /2)
{
fishImg.add(count2, fish);
position2[count2][0] = x;
position2[count2][1] = y2;
count2++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment