////James Doyle Project 1 //global date float horizon; float bombX=0, bombY=0, bombDY=0; //no bomb until Y>0 float gravity=1*9.81/frameRate; int guyX=100,guyY=100,guyDX=10,guyDY=5; int birdX=100; int birdY=100; // Initial position of bird int birdDX=3; int defX=100, defY=600, defDX=20, defDY=10; //def bounces int sunX=10, sunY=100; //position of sun color c; int speed; boolean eastbound=true; void setup() { size(1000,800); smooth(); frameRate(10); speed=(int) frameRate; noCursor(); } void draw() { ///draw everything scene(); guy(); stick(); dog(); puck(); def(); defstick(); bird(); } void scene() { ///background sky grass background (0,0,250); fill(255,255,0); ellipse(sunX, sunY, 50, 50); //Sun fill(255,255,255); sunX = (sunX+1) % width; //sun path float sun= (float) sunX / width; sunY =(int)(150-100*sin(PI*sun)); horizon=height/3; rectMode(CORNERS); rect(0,height/3, width, height); fill(0,0,0); text("James Doyle, CST 112, Project 0",10,790); //clouds strokeWeight(0); fill(255,255,255,200); rect(0,0,width,30); fill(255,255,255,150); rect(0,0,width,20); fill(255,255,255,100); rect(0,0,width,10); strokeWeight(2); } void guy() { ///guy follows mouse fill(0,0,255); //shirt rectMode(CENTER); rect(mouseX,mouseY, 50,70); fill(255,255,255); //stripe rect(mouseX,mouseY+18,50,7); fill(255,127,0); //crest ellipseMode(CENTER); ellipse(mouseX,mouseY-9,30,30); fill(255,127,0); //pants rect(mouseX,mouseY+40,50,25); fill(225,225,225); //left shin rect(mouseX-12,mouseY+70,20,40); fill(225,225,255); //right shin rect(mouseX+12,mouseY+70,20,40); fill(255,255,140); //head //////details ellipse(mouseX,mouseY-50,30,30); fill(0,0,0); //helmet rect(mouseX,mouseY-65,35,10); fill(0,0,0);//left ear flap rect(mouseX-15,mouseY-55,5,10); fill(0,0,0);//right ear flap rect(mouseX+15,mouseY-55,5,10); fill(0,0,0); //left eye ellipse(mouseX-4,mouseY-52,3,3); fill(0,0,0); //right eye ellipse(mouseX+4,mouseY-52,3,3); fill(0,0,0); //left skate rect(mouseX-16,mouseY+85,28,10); fill(0,0,0); //right skate rect(mouseX+16,mouseY+85,28,10); strokeWeight(1); //left skate blade fill(210,210,210); rect(mouseX-16,mouseY+92,28,3); fill(210,210,210); //right skate blade rect(mouseX+16,mouseY+92,28,3); strokeWeight(2); fill(0,0,255); //left arm rect(mouseX-23,mouseY,10,55); fill(0,0,255); //right arm rect(mouseX+23,mouseY,10,55); } void stick() { ///attempt at a hockey stick strokeWeight(5); line(mouseX-23,mouseY+18,mouseX+50,mouseY+80);//position of stick strokeWeight(10); line(mouseX+50,mouseY+80,mouseX+70,mouseY+80);//position of blade strokeWeight(2); } void puck() { //puck is on the stick fill(0,0,0); rectMode(CENTER); rect(pmouseX+90,pmouseY+80,15,5);//position of the puck } void def() { //def moves and bounces off walls defDX= defX>50 && defXhorizon && defY150) { birdY=birdY-5; } else if(birdY<-200) { birdY=birdY-10; } if(bombX>0) { //drops from bird bombX=birdX-5; bombDY=bombDY+gravity; bombY+=bombDY; if(bombY>height) { bombY=0; background(255); } fill(60,60,60); //bomb ellipseMode(CENTER); triangle(bombX-12,bombY-15,bombX+12,bombY-15,bombX,bombY+15); fill(40,40,40); ellipse(bombX,bombY,16,30); } }