//// Danielle Reese: Midterm //// title: MIDTERM ///GLOBAL DECLARATIONS/// float surface; float jellyfishX, jellyfishY, jellyfishDX=5, jellyfishDY, jellyfishW=100, jellyfish=100; float jellyfishR, jellyfishB, jellyfishG, jellyfishH; float sunX, sunY, sunDX=1; float shipX, shipY, shipDX=2, shipDY=0, shipW=100, shipH=20; float octoX, octoY, octoDX=2, octoDY=-2, octoW=60, octoH=120; float octoR, octoG, octoB; int numjellyfish=4; float top; float bottom; float left, right; //Size, reset, etc. void setup() { size(600, 400); surface= height/3; bottom= height; left=20; right=width-40; reset(); } void reset(){ jellyfishX= 0; jellyfishY= random(20,surface); jellyfishDX=random(1,10); jellyfishDY=0; jellyfishR=random(100,255); jellyfishG=random(200); jellyfishB=random(200); jellyfishW= 60* random(0.5,3.0); jellyfishH= jellyfishW/5; numjellyfish= int(random(1,10) ); octoReset(); } void octoReset() { octoX= random(left, right); octoY= bottom-20; octoR= random( 25, 175); octoG= random( 0, 100); octoB= random( 200, 255); octoDY= -2; octoDX= 0.5; } void draw(){ scene(); ship(); octo(); grading(); } ///scene: sky, sun, ocean void scene(){ background(0,0, 250); //ocean fill(0, 200, 0); rectMode(CORNER); rect(0, height*1/3, width, height*3/4); sunX+= sunDX; sunX= sunX % width; sunY= surface -100*sin(PI * sunX/width); fill( 255, 200,0); ellipse( sunX, sunY, 50, 50); } void ship() { shipX += shipDX; shipY= top-20; if(shipX > width || shipX<0) shipDX= -shipDX; fill(255, 0,0); rect( shipX, shipY, shipW,shipH); rect( shipX-10, shipY+124, shipW-50, shipH+10); //size and postion of ship } void octo() { if (octoY < surface) octoDY = +5; if (octoY > bottom) octoReset(); octoX += octoDX; octoY += octoDY; fill(0); if (octoY < top-20); /* octoY= bottom; octoX= random( left, right); */ octoR= random( 40, 150); octoG= random( 50, 100); octoB= random( 200, 255); text( octoX, 200,310 ); text( octoY, 200,320 ); text( bottom, 200,349 ); octoDraw(); } void octoDraw() { // Draw the octo rect(octoX+octoW/2, octoY+octoH/2, octoW, octoH); ellipse( octoX+50, octoY, octoW, octoH); fill(255); ellipse(octoX+50, octoY-5, 20, 30); fill(0); ellipse( octoX+50, octoY-5, 5, 10); fill(0); ellipse( octoX+50, octoY-5, 5, 10); } /* void setup(){ size(600,400); } void draw() { grading(); } */ void grading() { }