int score=500; float sunX=100, sunY=100; float horizon; float plueX, plueY; float enemyX, enemyY; float goldX, goldY; //plueX=plueX + (enemyX-plueX)/50; //plueY=plueY + (enemyY-plueY)/50; void setup() { //setup// size(1100, 900); horizon= height/2; sunY= horizon/2; plueX=width/2; plueY=height/2; enemyX=30; enemyY=random(horizon, height-60); goldX=width-50; goldY= random(horizon+50, height-50); } void draw() { //next frame// scene(); gold(); hero(); monster(); scoring(); } void scene() { //sky, sun, etc. background(200, 200, 255); fill(255, 255, 0); ellipse(sunX, sunY, 250, 250); fill(200, 255, 200); rectMode(CORNER); rect(0, horizon, width, height*3/4); // sun moves across sky // if (sunX > width) { sunX=0; sunY= random(30, horizon-30); score= score+100; } sunX= sunX+1; fill(0); // text(sunX, sunX, sunY+40); text( "SCORE= " + score, width-200, 50); } void hero() { // move & draw Plue // plueX= plueX + (mouseX-plueX)/30; plueY= mouseY + (mouseY-plueY)/30; //head// fill(0, 255, 0); ellipse(plueX, plueY, 195, 200); //nose// fill(237, 82, 63); rect(plueX-20, plueY-10, 40, 40); //eyes // fill(255); ellipse(plueX-50, plueY-20, 40, 40); ellipse(plueX+50, plueY-20, 40, 40); fill(0, 9, 222); ellipse(plueX+50, plueY-20, 10, 10); ellipse(plueX-50, plueY-20, 10, 10); //mouth// fill(255, 82, 96); ellipse(plueX, plueY+60, 50, 30); //body// fill(167, 9, 257); rectMode(CENTER); rect(plueX, plueY+200, 200, 200); //legs// fill(0, 200, 255); rect(plueX+50, plueY+360, 50, 100); rect(plueX-50, plueY+360, 50, 100); //hands// fill(255, 160, 0); rect(plueX+150, plueY+40, 50, 190); rect(plueX-150, plueY+40, 50, 190); //name// fill(0); text( "PLUE", plueX-20, plueY+200 ); //gold scoring// if ( dist( plueX, plueY, goldX, goldY ) < 50 ) { score += 50; background(255, 255, 255); reset(); } } void monster() { //move and draw enemy// //chase plue enemyX= enemyX + (plueX-enemyX)/150; enemyY= enemyY + (plueY-enemyY)/150; if (dist(plueX, plueY, enemyX, enemyY) < 105) { eat(); } //draw Enemy// //head// fill(255); ellipse(enemyX, enemyY, 195, 200); //nose// fill(237, 82, 0); rectMode(CENTER); rect(enemyX, enemyY, 40, 40); //eyes // fill(255); ellipse(enemyX-50, enemyY-20, 40, 40); ellipse(enemyX+50, enemyY-20, 40, 40); fill(255, 9, 6); ellipse(enemyX-50, enemyY-20, 10, 10); ellipse(enemyX+50, enemyY-20, 10, 10); //black brows// fill(0); rectMode(CENTER); rect(enemyX, enemyY-45, 140, 9); //mouth// fill(255, 82, 96); ellipse(enemyX, enemyY+60, 50, 30); //body// fill(87, 169, 2); rectMode(CENTER); rect(enemyX, enemyY+200, 200, 200); //legs// fill(0); rect(enemyX+50, enemyY+360, 50, 70); rect(enemyX-50, enemyY+360, 50, 70); //hands// fill(255, 0, 0); rect(enemyX+180, enemyY+150, 110, 50); rect(enemyX-180, enemyY+150, 110, 50); //name// fill(255); text( "ENEMY ", enemyX-20, enemyY+200 ); //gold scoring// if ( dist( goldX, goldY, enemyX, enemyY ) < 50 ) { goldX= 50; goldY= random(horizon, height); } } void gold() { // Draw the gold. // if (goldY>horizon) { fill(random(250), random(200), random(150)); ellipse( goldX, goldY, 40+random(10), 40+random(10) ); fill(random(250), random(200), random(100)); ellipse( goldX, goldY, 30+random(5), 30+random(5) ); fill(255, 255, 0); ellipse( goldX, goldY, 20+random(10), 20+random(10) ); } } void scoring() { } void reset() { // Start at corners. // goldX= random( width/4, width*3/4); goldY= random(horizon+20, height-20); ; //plueX= width; //plueY= height; //enemyX=0; //enemyY=horizon; } void eat() { //Monster kills hero. Deduct 200 from score.// score= score - 200; background(255, 0, 0); plueX= width/2; plueY= height/2; enemyX= width/2; enemyY= height/2; enemyX=0; } void mousePressed() { // plueX= mouseX; plueY= mouseY; score= score - 50; enemyX=0; }//