//Philip Paniccia //Moving String author="Philip Paniccia"; int speed = 2; float x,y,w,h; float chipX, chipY; float brickX, brickY; float goldX, goldY; float sunX, sunY; float horizonX, horizonY; int score = 0; float birdX, birdY; float ladX, ladY; int n; // # of pairs in flock void setup() { size(800,500); rectMode(CENTER); horizonX=2000; horizonY= 150; points(); x= width/2; y= horizonY-100; w= 60; h= 20; n= int( random(1,3) ); brickX= 2; brickY= 1; goldX= random(width); goldY= random(180, height); sunX= 25; sunY= 25; birdX=25; birdY=50; ladX= width- 50; //ladY= horizonY; } void draw() { //Next frame// background(0,175,0); horizon(); rectMode(CENTER); chipX= chipX + (mouseX-chipX)/5; if(chipYwidth*2 && x<0); // gold(); sun(); grass(); // leadBird( x,y,w,h); flock(n,x,y,w,h); if (x>width*2) flockReset(); // bird1(); bombReset(); ladder(); chip(); brick(); points(); // text(author, 10, height-20); text( "horizonY", 100,horizonY ); } void brick() { //make Brick move// brickX= brickX + (goldX-brickX)/100; brickY= brickY + (goldY-brickY)/100; brickX= brickX + (chipX-brickX)/25; brickY= brickY + (chipY-brickY)/25; //Draw Brick// stroke(0); fill(255,0,0); rect(brickX,brickY, 50,50); ellipse(brickX,brickY-25,25,25); line(brickX-25,brickY-25, brickX-25-50,brickY-25-10 ); //left arm line(brickX+25,brickY-25, brickX+25+50,brickY-25-10 ); //right arm line(brickX+10,brickY+25,brickX+10,brickY+50); //right leg line(brickX-10,brickY+25,brickX-10,brickY+50); //left leg fill(255,255,150); triangle(brickX+25,brickY-35,brickX-25,brickY-35,brickX,brickY-50); //hat fill(255,0,0); text(brickX, 20,100); text(brickY, 20,110); } void chip() { //draw chip// stroke(0); fill(0,0,255); rect(chipX, chipY, 35,35); //make chip move via mouseX, mouseY ellipse(chipX,chipY-25,15,15); line(chipX-18,chipY-17,chipX-35,chipY+15); //left arm line(chipX+18, chipY-17, chipX+35,chipY+15); //right arm line(chipX+8,chipY+17,chipX+8,chipY+35); //right leg line(chipX-8,chipY+17,chipX-8,chipY+35); //left leg fill(255,255,150); triangle(chipX+15,chipY-25,chipX-15,chipY-25,chipX,chipY-35); fill(0,0,255); text( chipX, 20,50 ); text( chipY, 20,60 ); } void bird1(){ //whit bird flys across sky while flapping wings float flap=0; float x=birdX+30, w=60, h=15; stroke(2); fill(255); // triangle(birdX+30,birdY, birdX-15,birdY-5, birdX-15,birdY+5); triangle( x,birdY, x-w, birdY-h, x-w,birdY+h); birdX= (birdX+2.5) % width; //make bird move int n= int(birdX/50); if(n % 4 == 0) flap= 20; else if(n % 4 == 1) flap= -10; else if(n % 4 == 2) flap= -20; else if(n % 4 == 3) flap= +10; else text( "HELP!", 300,300); fill(200); triangle(birdX,birdY, birdX-w/3,birdY-flap, birdX-5,birdY); } void gold() { //draw gold fill(255,175,0); ellipse(goldX,goldY, 20,20); } void bombReset(){ //bomb which is dropped from bird to land on Brick fill(0); ellipse(birdX,birdY, 10,10); } void sun() { //draw sun stroke(2); fill(255,255,0); ellipse(sunX,sunY,25,25); sunX= (sunX + 1) % width; //Make sun move and reset score= score -1; //as sun moves, it deducts a single point for every pixel } void flock( int n, float x, float y, float w, float h){ //birds that follow behind lead bird, pairs change text( n, 10,10 ); float updown=0; for (int j=0; j0; j-=20){ line(ladX-50, ladY, ladX, ladY); ladY -=20; } //darw man stroke(0); fill(0,0,255); rect(ladX/2, ladY/2, 35,35); ellipse(ladX,ladY-25,15,15); line(ladX-18,ladY-17,ladX-35,ladY-15); //left arm line(ladX+18, ladY-17, ladX+35,ladY-45); //right arm line(ladX+8,ladY+17, ladX+8,ladY+35); //right leg line(ladX-8,ladY+17, ladX-8,ladY+35); //left leg } void mousePressed(){ //cheat, get half points goldX= mouseX; goldY= mouseY; //score= score -50; } void points(){ //if Chip get to the coin, score adds 100 points if(dist(chipX,chipY, goldX,goldY) <25){ background(255,175,0); fill(0,255,0); textSize(75); text("MONEY!",chipX,chipY); reset(); score= score +100; } //if Brick gets to Chip, before Chip gets to coin, subtracts 500 points if(dist(brickX, brickY, chipX,chipY) <25){ background(0); fill(255,0,0); textSize(75); text("DEAD!", chipX,chipY); reset(); score= score -500; } fill(0); textSize(11); text("Score:",5,75); text(score,100,75); } void reset() { // gold goes to random position on screen, brick follows goldX= random( width); goldY= random(180,height); chipX= mouseX; chipY= mouseY; brickX= goldX; brickY= goldY; //score= score-50; } void flockReset() { //reset flock of birds in sky x= 100; y= random( 0, horizonY/2 ); w=60; h=20; n= int( random(1,4) ); fill( random(255), random(255), random(255) ); } void keyPressed(){ //exit/reset game// if(key == 'q') exit(); if(key == 'r') reset(); if(key == 'f') flockReset(); }