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