//Eric Hammond - 10/10/2012 - Arguments// //Globals int score = 0; float goldX = 100, goldY = 100, goldR = 50; float diamondX = 50, diamondY = 50; float diamondX2 = diamondX + 25, diamondY2 = diamondY + 25; float diamondX3 = diamondX + 50, diamondY3 = diamondY; float diamondX4 = diamondX + 25, diamondY4 = diamondY - 25; //Size void setup() { size(800, 600); } void draw() { scene(); valuables(); } // Backround and lettering void scene() { //// scene + score background( 200,200,255 ); fill(1); text( score, width-50, 20 ); fill(1); text("Eric Hammond CST 112 Proj 1.1", 20, 590); } void valuables() { //// Draw gold & gems if (goldX>0) { fill(255,255,0); ellipse( goldX,goldY, goldR,goldR ); } diamondX2 = diamondX + 25; diamondY2 = diamondY + 25; diamondX3 = diamondX + 50; diamondY3 = diamondY; diamondX4 = diamondX + 25; diamondY4 = diamondY - 25; if (diamondX>0) { fill(240, 240, 240); quad(diamondX, diamondY, diamondX2, diamondY2, diamondX3, diamondY3, diamondX4, diamondY4 ); } } void mousePressed() { //// Check if click on/near gold if ( far( mouseX, mouseY, goldX, goldY ) < ( goldR - 24 )) { //// if yes -- add score + 100 & set goldX = 0 score += 100; goldX = 0; } //if // Check if click on/near diamond //{ // score +=300; // diamondX = 0; //} } void keyPressed() { if (key == 'g') { goldX = random(20, width-goldR); goldY= random(20, height-goldR); } if (key == 'd') { diamondX = random(20, width-50); diamondY = random(20, height-50); } } float far(float x1, float y1, float x2, float y2) { //// Distance between points float r; float dx= x1 - x2; float dy= y1 - y2; r = sqrt((dx * dx) + (dy * dy)); return r; }