//Adam Kochen //Midterm float birdX = 600; int day = 1; String title = "CST112 Midterm"; String name = "Adam Kochen"+day; void setup(){ size(600,500); } void draw(){ if(day == 1){ background(50,200,255); //sky fill(255,0,255); sun(width*3/4,width*3/4); } else{ background(0,0,120); } fill(0); text(title+ name,240,20); //title noStroke(); fill(0,0,180); rect(0,height*1/4,width,height*3/4); //surface borders(); birdX-=5;//move bird bird(birdX,70); if(birdX + 50 < 0){ reset(); } fill(0,255,0); button(30,60,30,60,33,50); } void borders(){ //side borders for(float side = 0;side < height+10; side = side + 15){ fill(255,255,0); rect(0,side,10,10); //left ellipseMode(CENTER); fill(0,255,255); ellipse(width,side+5,10,10); //right } //top border for(float top = 0; top < width-15; top = top + 15){ fill(255,0,255); triangle(top+10,0,top+19,0,top+15,9); } stroke(0,255,0); for(float grassX = 15 ; grassX < width-10 ; grassX = grassX + 10){ strokeWeight(3); line(grassX,height,grassX,height-10); } } void bird(float bX, float bY){ noStroke(); //draw bird fill(120,0,120); triangle(bX,bY+5,bX,bY+15,bX-20,bY+10); triangle(bX+10,bY-5,bX+10,bY+25,bX-10,bY+10); } void reset(){ birdX = birdX + 800; } void button(float x, float w, float y, float h, float tx, float ty){ String text = "night"; if(mousePressed && mouseX < w && mouseX > x && mouseY < h && mouseY > y) { if(day == 1) { text = "night"; day = 2; } else{ if(day == 2){ day = 1; text = "day"; } } } rect(x,y,w-x,h-y,15); fill(0); text(text,tx,ty); } void sun(float x, float y){ ellipse(x,y,20,20); }