< Bonus: Arduino Alıştırma: Agar.io gibi bir şey >
void setup() {
size(288, 512);
kusX = 40;
kusY = 60;
kus1 = loadImage("bird1.png");
kus2 = loadImage("bird2.png");
kus3 = loadImage("bird3.png");
kus4 = loadImage("bird4.png");
arkaPlan = loadImage("back.png");
ustEngel = loadImage("engelUst.png");
altEngel = loadImage("engelAlt.png");
sayac = 1;
arkaPlanX = 0;
engelX = width;
engelY = 0;
}
int kusX;
float kusY;
int arkaPlanX;
int engelX;
int engelY;
PImage kus1;
PImage kus2;
PImage kus3;
PImage kus4;
PImage arkaPlan;
PImage ustEngel;
PImage altEngel;
int sayac;
int animasyonHizi = 10;
float kusHizY = 2;
float ivme = 0.3;
int arkaPlanHizX = -2;
int engelHizX = -4;
int engelBoslugu = 120;
void draw() {
background(255);
float kusSagUstX = kusX + 34;
float kusSagUstY = kusY;
float kusSagAltX = kusX + 34;
float kusSagAltY = kusY + 24;
if ((kusSagUstX > engelX && kusSagUstX < engelX + 56 && kusSagUstY < engelY + 272)
|| (kusSagAltX > engelX && kusSagAltX < engelX + 56 && kusSagAltY > engelY+272+engelBoslugu)) {
background(255, 0, 0);
} else {
image(arkaPlan, arkaPlanX, 0, width, height);
image(arkaPlan, arkaPlanX+width, 0, width, height);
image(ustEngel, engelX, engelY, 56, 272);
image(altEngel, engelX, engelY+272+engelBoslugu, 56, 240);
if (sayac > 0*animasyonHizi && sayac <= 1*animasyonHizi) {
image(kus1, kusX, kusY, 34, 24);
} else if (sayac > 1*animasyonHizi && sayac <= 2*animasyonHizi) {
image(kus2, kusX, kusY, 34, 24);
} else if (sayac > 2*animasyonHizi && sayac <= 3*animasyonHizi) {
image(kus3, kusX, kusY, 34, 24);
} else if (sayac > 3*animasyonHizi && sayac <= 4*animasyonHizi) {
image(kus4, kusX, kusY, 34, 24);
}
sayac = sayac + 1;
if (sayac > 4*animasyonHizi) {
sayac = 1;
}
kusY = kusY + kusHizY;
kusHizY = kusHizY + ivme;
arkaPlanX = arkaPlanX + arkaPlanHizX;
if (arkaPlanX < -width) {
arkaPlanX = 0;
}
engelX = engelX + engelHizX;
if (engelX < -56) {
engelX = width;
engelY = (int)random((height - (272+engelBoslugu+240)), 0);
}
}
}
void mousePressed() {
kusHizY = -6;
}