// Poject 1 // Yennifer Tejada int score = 0; float horizon; float sunX= 100; float sunY = 100; //float fritoX= 300, fritoY=300; // monster //PFont f; float goldX; float goldY; float platanoX; float platanoY; float fritoX; float fritoY; void setup() //setup { size(900,600); horizon = height/2; sunY= horizon/2; platanoX = width/2; platanoY = height/2; fritoX = 40; fritoY= random(horizon,height - 60); goldX=width-40; goldY= random(horizon+40,height-40); } void draw() { scene(); hero(); monster(); gold(); // reset(); textSize(15); fill(0); text( " Please don't hurt me " ,platanoX,platanoY-65); text("Score= "+score,50,50); text("Frito chases hero Platano",350,25); text("Author: Yennifer Tejada",30,590); } void scene() { background(65,142,247); fill(50,165,25); rectMode(CORNER); rect(0,horizon,width,height* 3/4); if (sunX > width) { sunX = 0; sunY = random (20, horizon-20); } fill(255,255,0); ellipse(sunX,sunY,55,55); sunX = sunX + 1.5; } void hero() // move and draw platano { platanoX = platanoX +(goldX-platanoX)/90; platanoY = platanoY + (goldY-platanoY)/90; fill(250,10,14); rectMode(CENTER); // platano's legs fill(0); rect(platanoX-15,platanoY+50, 15,55);// left leg rect(platanoX+15,platanoY+50, 15,55);//right leg fill(255); rect(platanoX, platanoY,50,80); // body // platano's arms rect(platanoX-35,platanoY-10, 20,60);// left arm rect(platanoX+35,platanoY-10, 20,60);//right arm if (dist( platanoX,platanoY,goldX, goldY) <50) { score += 200; background (0,0,255); reset(); } fill(232,234,117); ellipse(platanoX,platanoY-40, 40,50); //head fill(82,185,247); ellipse(platanoX-10, platanoY-50, 10,15); // left eye ellipse(platanoX+10, platanoY-50, 10,15); // right eye fill(0); ellipse(platanoX, platanoY-30, 10,15); // mouth } void monster() { // chase platano fritoX= fritoX + (platanoX - fritoX)/150; fritoY= fritoY + (platanoY - fritoY)/150; //monster gets hero if (dist(platanoX,platanoY, fritoX, fritoY) < 50 ) { eat(); } fill(234,25,17); rectMode (CENTER); fill(0,255,0); ellipse(fritoX , fritoY, 70,90); // body fill(125,126,115); ellipse(fritoX-45,fritoY-10, 25,50);// left arm ellipse(fritoX+45,fritoY-10, 25,50);//right arm fill(234,225,117); ellipse(fritoX, fritoY-40,50,60);// head // eyes,eyebrows and mouth of the monster fill(0,15,20); ellipse(fritoX-10, fritoY-50, 10,15); // left eye ellipse(fritoX+10, fritoY-50, 5,10); // right eye ellipse(fritoX, fritoY-20, 20,5); // mouth rect(fritoX, fritoY-60, 30,5); //eyesbrows ellipse(fritoX-20,fritoY+55, 25,60);//right leg ellipse(fritoX+20,fritoY+55, 25,60);//right leg // monster gets gold if ( dist( goldX,goldY, fritoX,fritoY ) < 50 ) { goldX= 50; goldY= random(horizon,height); } } void eat() { // monster eats hero! deduct 20 from score score= score - 20; background(0); reset(); } void mousePressed() { goldX = mouseX; goldY = mouseY; score = score -50; fritoX=0; fritoY=horizon; } void gold() { if (goldY>horizon) { fill(201,172,24); rect(goldX,goldY,20,20); rect(goldX,goldY,40,20); rect(goldX,goldY,40+random(5),20+random(5)); } } void reset() { goldX= random(width/2,width*3/4); goldY= random(horizon+10,height-10); platanoX= width; platanoY= height; fritoX=0; fritoY=horizon; }