Hain Kuzu - Kuzuyu Karşıya Geçir
Oyun Görüntü ve Kod Dosyaları :
Kaynak Kodu :
//JAVA Processing Environment
//zafercavdar
PImage img;
PImage img2;
PImage img3;
PImage car;
PImage mole;
int en=800, boy=600;
int a=30, b=150, c=270, d=390, e=510;
int sheepX = 670, sheepY = boy/2-10;
int citX = 20, citY = boy/2-40;
int score = 0;
int car1X = 250, car2X = 405, carY = 0;
int zar, tempx;
void setup()
{
img = loadImage("sheep.png");
img2 = loadImage ("cit.png");
img3 = loadImage ("cim2.jpg");
car = loadImage ("car.png");
mole = loadImage ("mole.png");
size (en, boy, P3D);
textFont(loadFont("Score.vlw"));
fill(0);
zar = int (random (2));
}
void draw()
{
background(170, 170, 170);
set(0, 0, img3);
set(551, 0, img3);
strokeWeight(10);
line (250, 0, 250, boy);
line (550, 0, 550, boy);
printScore();
frameRate(120);
if (a > boy)
a=0;
if (b > boy)
b=0;
if (c > boy)
c=0;
if (d > boy)
d=0;
if (e > boy)
e=0;
strokeWeight(8);
drawSerit();
//roadMove();
int speed = 5;
if (carY > boy)
{
zar = int (random (2));
speed = int (random(5)) + 1 ;
carY = -30;
}
else
{
if (zar == 0)
tempx = car1X;
if (zar == 1)
tempx = car2X;
strokeWeight(0);
pushMatrix();
translate(tempx, carY);
scale(140, 123);
drawCar();
popMatrix();
carY += speed;
}
strokeWeight(0);
pushMatrix();
translate(sheepX, sheepY);
scale(70);
drawSheep();
popMatrix();
if (sheepX <= 110 && sheepY <= 310 && sheepY >= 250)
{
score++;
sheepX = 670;
sheepY = int (random(boy-101)) + 20;
}
strokeWeight(0);
pushMatrix();
translate(citX, citY);
scale(200, 114);
drawCit();
popMatrix();
if (sheepX >= tempx & sheepX <= tempx + 140 && sheepY >= carY && sheepY <= carY + 123 )
{
score -- ;
sheepX = 670;
sheepY = int (random(boy-101)) + 20;
}
if (score == 10)
{
background(0);
set(0, 0, mole);
textFont(loadFont("Score.vlw"));
}
}
void roadMove()
{
a += 1;
b += 1;
c += 1;
d += 1;
e += 1;
}
void printScore()
{
fill (0, 0, 0);
text("SCORE : " + score, 565, 40);
}
void drawSerit()
{
stroke(0);
line (400, a, 400, a+60);
line (400, b, 400, b+60);
line (400, c, 400, c+60);
line (400, d, 400, d+60);
line (400, e, 400, e+60);
}
void drawSheep()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(img);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void drawCar()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(car);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void drawCit()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(img2);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void keyPressed()
{
if (keyCode == LEFT && sheepX >= 20)
sheepX -= 20;
if (keyCode == RIGHT && sheepX <= en-81)
sheepX += 20;
if (keyCode == UP )
//if (sheepX >= 550 || sheepX <= 210)
if (sheepY >= 20)
sheepY -= 20;
if (keyCode == DOWN )
//if (sheepX >= 550 || sheepX <= 210)
if (sheepY <= boy-81)
sheepY += 20;
}
//zafercavdar
PImage img;
PImage img2;
PImage img3;
PImage car;
PImage mole;
int en=800, boy=600;
int a=30, b=150, c=270, d=390, e=510;
int sheepX = 670, sheepY = boy/2-10;
int citX = 20, citY = boy/2-40;
int score = 0;
int car1X = 250, car2X = 405, carY = 0;
int zar, tempx;
void setup()
{
img = loadImage("sheep.png");
img2 = loadImage ("cit.png");
img3 = loadImage ("cim2.jpg");
car = loadImage ("car.png");
mole = loadImage ("mole.png");
size (en, boy, P3D);
textFont(loadFont("Score.vlw"));
fill(0);
zar = int (random (2));
}
void draw()
{
background(170, 170, 170);
set(0, 0, img3);
set(551, 0, img3);
strokeWeight(10);
line (250, 0, 250, boy);
line (550, 0, 550, boy);
printScore();
frameRate(120);
if (a > boy)
a=0;
if (b > boy)
b=0;
if (c > boy)
c=0;
if (d > boy)
d=0;
if (e > boy)
e=0;
strokeWeight(8);
drawSerit();
//roadMove();
int speed = 5;
if (carY > boy)
{
zar = int (random (2));
speed = int (random(5)) + 1 ;
carY = -30;
}
else
{
if (zar == 0)
tempx = car1X;
if (zar == 1)
tempx = car2X;
strokeWeight(0);
pushMatrix();
translate(tempx, carY);
scale(140, 123);
drawCar();
popMatrix();
carY += speed;
}
strokeWeight(0);
pushMatrix();
translate(sheepX, sheepY);
scale(70);
drawSheep();
popMatrix();
if (sheepX <= 110 && sheepY <= 310 && sheepY >= 250)
{
score++;
sheepX = 670;
sheepY = int (random(boy-101)) + 20;
}
strokeWeight(0);
pushMatrix();
translate(citX, citY);
scale(200, 114);
drawCit();
popMatrix();
if (sheepX >= tempx & sheepX <= tempx + 140 && sheepY >= carY && sheepY <= carY + 123 )
{
score -- ;
sheepX = 670;
sheepY = int (random(boy-101)) + 20;
}
if (score == 10)
{
background(0);
set(0, 0, mole);
textFont(loadFont("Score.vlw"));
}
}
void roadMove()
{
a += 1;
b += 1;
c += 1;
d += 1;
e += 1;
}
void printScore()
{
fill (0, 0, 0);
text("SCORE : " + score, 565, 40);
}
void drawSerit()
{
stroke(0);
line (400, a, 400, a+60);
line (400, b, 400, b+60);
line (400, c, 400, c+60);
line (400, d, 400, d+60);
line (400, e, 400, e+60);
}
void drawSheep()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(img);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void drawCar()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(car);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void drawCit()
{
textureMode(NORMALIZED);
beginShape(QUADS);
texture(img2);
vertex(0, 1, 0, 0, 1);
vertex(1, 1, 0, 1, 1);
vertex(1, 0, 0, 1, 0);
vertex(0, 0, 0, 0, 0);
endShape(CLOSE);
}
void keyPressed()
{
if (keyCode == LEFT && sheepX >= 20)
sheepX -= 20;
if (keyCode == RIGHT && sheepX <= en-81)
sheepX += 20;
if (keyCode == UP )
//if (sheepX >= 550 || sheepX <= 210)
if (sheepY >= 20)
sheepY -= 20;
if (keyCode == DOWN )
//if (sheepX >= 550 || sheepX <= 210)
if (sheepY <= boy-81)
sheepY += 20;
}