//Lanipse Rosario //Joe on grass loop //project #4 float x,topX; float position=0; //-1 to 1 float centerX; //screen center int joeX, joeY; int dX, dY; void setup() { size(640,480); centerX=width/2; } void draw()// draw scene etc { Scene(); drawJoe(); moveJoe(); } void Scene() /// sky, sun, waving grass { background(100,200,255); ///grass at bottom for( x=0; x<=width; x+=5) { topX=x+10*position; stroke(5); strokeWeight(2); stroke(100,255,100); line(x,height,topX,height-30); } } void drawJoe()///draw joe { strokeWeight(0); stroke(0); rect(joeX,joeY,80,80); } void moveJoe()//joe moves towards the mouse { dX = (mouseX-joeX)/30; dY = (mouseY-joeY)/30; joeX = joeX+dX; joeY = joeY+dY; position = (joeX - centerX)/centerX; }