//p1 //alex Dahlgren Project 1 float alexX, alexY; //hero float johnX, johnY; //monster float horizon; float sunPX = 3, sunPY; float sunX, sunY; //sun placement void setup() { size( 640, 480); frameRate( 30 ); johnX = pmouseX; johnY = pmouseY; alexX = width*3/5; alexY = height*3/5; sunX = width*4/5; sunY = height/5; horizon = height/3; } void draw() { //new frame scene(); john(); alex(); } void scene(){ background( 50, 200, 250); fill(200,0,00); textSize(10); text("John the monster chases the hero alex", 20,20); fill(200,0,0); textSize(10); text("Alex Dahlgren, project 1 3/23/15", 20,10); house(); sun(); //grass fill(0,250,0); rectMode(CORNER); rect(0,horizon, width, height*3/4); fill( 255, 240, 3); ellipseMode(CENTER); noStroke(); ellipse( sunX, sunY, 30,30); //trees fill(0,250,0); noStroke(); rectMode(CENTER); rect(200,horizon,10,100); rect(400,horizon,10,100); rect(600,horizon,10,100); rect(0,horizon,10,100); ellipseMode(CENTER); fill(0); ellipse(200, horizon-56,20,20); ellipse(400, horizon-56,20,20); ellipse(600, horizon-56,20,20); ellipse(0, horizon-56,20,20); } void sun() { sunX = sunX + sunPX; sunX = sunX % width; sunY = horizon - 100*sin(PI * sunX/width); //sun rise +fall horizon = height/3; } void house() { float houseX, houseY; houseX=width*1/2; houseY=horizon-20; fill(0,0,120); noStroke(); rectMode(CENTER); rect(houseX, houseY, 40,50); fill(255,0,20); triangle( houseX-30, houseY-20, houseX+30, houseY-20, houseX, houseY-100); //aestetics fill(255,0,0); rect(houseX+10,houseY-10,10,10); rect(houseX-10,houseY-10,10,10); rect(houseX,houseY+15,5,10); } void alex() { alexX = (mouseX); alexY = (mouseY); fill(0); noStroke(); rectMode(CENTER); rect(alexX,alexY, 20,40); ellipseMode(CENTER); fill(0); ellipse(alexX,alexY-30,20,20); //legs rect(alexX-5,alexY+25,5,20); rect(alexX+5,alexY+25,5,20); //arms rect(alexX+5,alexY-10,35,5); rect(alexX-5,alexY-10,35,5); } void john () { johnY = johnY