//// Project 1 ////A.Urrutia, september 12 int score=0; float sunX=100, sunY=100; float horizon; float jaxX, jaxY; float dimitriusX, dimitriusY; void setup() { //// setup //// size ( 650,450 ); horizon= height/4; sunY= horizon/2; jaxX=width/2; jaxY= height/2; dimitriusX=30; dimitriusY= random( horizon,height-60 ); } void draw() { // next frame // scene(); hero(); monster(); scoring(); } void scene() { // sky, sun, etc. background( 200,200,200 ); fill(255,255,0); // yellow sun ellipse(sunX,sunY, 50,50); fill( 200,255,200); // grass rectMode( CORNER ); rect (0,horizon, width,height*3/4); // sun moves across sky // if (sunX > width) { sunX=0; sunY= random( 10, horizon-20); score= score+10; } sunX= sunX+2; fill(0); // text( sunX, sunX, sunY+40); text ( "SCORE= "+ score, width-200, 50 ); } void hero() { // move& draw Jax // jaxX= jaxX + (mouseX-jaxX)/30; jaxY= mouseY + (mouseY-jaxY)/30; // draw fill( 0,150,150); rectMode( CENTER ); rect( jaxX, jaxY, 50,85); fill(255,127,0); ellipse(jaxX,jaxY-40, 40,55); // arms rectMode( CORNERS ); fill(0); rect ( jaxX-30,jaxY-45, jaxX-30-70,jaxY-45+15 ); rect ( jaxX+30,jaxY-45, jaxX+30+70,jaxY-45+15 );; } void monster() { // move & draw Jax // // chase jax dimitriusX= dimitriusX + (jaxX-dimitriusX)/150; dimitriusY= dimitriusY + (jaxY-dimitriusY)/150; if ( dist( jaxX,jaxY, dimitriusX,dimitriusY ) < 50 ) { } // draw dimitrius // fill ( 150,0,0 ); rectMode( CENTER ); rect ( dimitriusX, dimitriusY, 70, 90 ); fill (127,255,0); ellipse (dimitriusX,dimitriusY-40, 50,65); // arms rectMode( CORNERS ); fill(0); rect ( dimitriusX-35,dimitriusY-45, dimitriusX-35-70,dimitriusY-45+15 ); rect ( dimitriusX+35,dimitriusY-45, dimitriusX+35+70,dimitriusY-45+15 ); } void scoring() { } void eat() { //// Monster eats hero!!!! DEeduct 200 from score. score= score - 200; background(255,0,255); jaxX= width; jaxY= height; dimitriusX=0; dimitriusY=horizon; } void mousePressed() { //// jaxX= mouseX; jaxY= mouseY; score= score - 60; dimitriusX=0; }