// The Seekers Version 2.0 // // Wally Glutton // http://www.stungeye.com // // Seekers set out to search for gold. If found, they will remember it's location // and begin transporting the gold home. Each time they arrive at the goldmine they // use their telepathy to inform one other seeker (choosen at random) of the location. // // Released under Creative Commons Attribution-ShareAlike 1.0 // http://creativecommons.org/licenses/by-sa/1.0/ // GOLDMINE CONSTANTS int NUMGOLDMINES = 15; int MINGOLDMINES = 1; int MAXGOLDSIZE = 25; int INITIALGOLD = 1000; // HOME CONSTANTS int HOMESIZE = 17; // SEEKER CONSTANTS int NUMSEEKERS = 50000; int MINSEEKERS = 50; int SEEKERSIZE = 3; float TRACKFACTOR = 0.1; float TRACKFACTORMARGIN = 0.05; int SEEKERSIGHT = 8; int NUMFRIENDS = 200; int MINNUMFRIENDS = 0; int CALLRANGE = 400; int MINCALLRANGE = 25; boolean SKIPFOUNDCHECK = true; // COLOUR CONSTANTS int GOLDCOLOUR = #FFFF00; int HOMECOLOUR = #00FF00; int FOUNDCOLOUR = #FF00FF; int SEEKCOLOUR = #0000FF; int PAYLOADCOLOUR = #FF0000; GoldMine[] goldMines; Home home; Seeker[] seekers; int currentNumSeekers = 250; int currentGoldMines = 1; int currentCallRange = 100; int currentNumFriends = 5; int seekerLandWidth,seekerLandHeight; BFont overBurnFont; BFont silkFont; boolean paused = false; boolean refresh = true; int numHandles = 4; Handle[] handles; void setup() { //smooth(); //framerate(12); size(600,400); seekerLandWidth = width - 200; seekerLandHeight = height; goldMines = new GoldMine[NUMGOLDMINES]; newGoldMines(); newHome(); seekers = new Seeker[NUMSEEKERS]; newSeekers(); overBurnFont = loadFont("Overload_Burn.vlw.gz"); silkFont = loadFont("Silkscreen.vlw.gz"); makeHandles(); } void loop() { int i = 0; if (refresh) background(0); else { noStroke(); fill(0); rect(400,0,600,400); } home.processTurn(); if (!paused) for(i=0; i < NUMSEEKERS; i++) seekers[i].processTurn(); for(i=0; i < currentGoldMines; i++) { if (goldMines[i].getContent() <= 0) { newGoldMine(i); } goldMines[i].display(); } home.display(); for(i=0; i < NUMSEEKERS; i++) seekers[i].display(); displayMenu(); for (i=0; i currentNumSeekers) { for(int i = currentNumSeekers; i < handles[0].currentValue; i++) { newSeeker(i); } } else if (handles[0].currentValue < currentNumSeekers) { for (int i = currentNumSeekers-1; i >= handles[0].currentValue; i--) { seekers[i].deactivate(); } } currentNumSeekers = handles[0].currentValue; } else if (handles[1].changed) // CALL RADIUS handle { currentCallRange = handles[1].currentValue; } else if (handles[2].changed) // NUM FRIENDS handle { currentNumFriends = handles[2].currentValue; } else if (handles[3].changed) // NUM MINES handle { //println("Handles:" + handles[3].currentValue + " current:" + currentGoldMines); if (handles[3].currentValue > currentGoldMines) { for(int i = currentGoldMines; i < handles[3].currentValue; i++) { newGoldMine(i); } } else if (handles[3].currentValue < currentGoldMines) { for (int i = currentGoldMines-1; i >= handles[3].currentValue; i--) { goldMines[i].deactivate(); } } currentGoldMines = handles[3].currentValue; } paused = false; } } // Handles 2 // Variation on Handles // by REAS // Click and drag the white boxes to change their position. // Created 10 February 2003 // Variation 15 January 2004 by K Pfeiffer // Upper half of the handles grab at the centerpoint // Lower half use centerpoint to mouseX offset so handles don't 'jump' when you grab them // // Modified April 2004 for use with the Seekers by Wally Glutton class Handle { int x, y; int minValue, maxValue; int currentValue; int xText, yText; int boxx, boxy; int length; int maxLength; int origLength; int size; boolean over; boolean press; boolean locked = false; boolean otherslocked = false; int offsetMouseX; // difference between mouseX and handle center when mousePressed Handle[] others; boolean isCircle; boolean changed; Handle(int _x, int _y, int _l, boolean c, int _s, int _minValue, int _maxValue, int startValue, int _xText, int _yText, Handle[] o) { x = _x; y = _y; minValue = _minValue; maxValue = _maxValue; currentValue = startValue; xText = _xText; yText = _yText; size = _s; maxLength = width-size-x-20; length = (int)((float)((currentValue*maxLength)-(minValue*maxLength)))/(maxValue-minValue) +10; origLength = 10; changed = false; boxx = x+length - size/2; boxy = y - size/2; others = o; isCircle = c; } void update() { boxx = x+length; boxy = y - size/2; changed = false; for(int i=0; i height/2) { offsetMouseX = -(mouseX-(x+length+size/2)); // difference between mouseX on press and center of handle } // keeps handle center from 'jumping' to curser hotspot press = true; locked = true; paused = true; } else { press = false; //paused = false; } } void release() { locked = false; } void display() { stroke(255); line(x, y, x+length, y); fill(255); stroke(0); if(isCircle == true) { ellipse(boxx, boxy, size, size); } else { rect(boxx, boxy, size, size); } if(over || press) { line(boxx, boxy, boxx+size, boxy+size); line(boxx, boxy+size, boxx+size, boxy); } textFont(silkFont,14); //text(temp,xText,yText); text(currentValue,xText,yText); } } boolean overRect(int x, int y, int width, int height) { if (mouseX >= x && mouseX <= x+width && mouseY >= y && mouseY <= y+height) { return true; } else { return false; } } boolean overCircle(int x, int y, int diameter) { float offsetX = x + diameter/2 - mouseX; float offsetY = y + diameter/2 - mouseY; if(sqrt(sq(offsetX) + sq(offsetY)) < diameter/2 ) { return true; } else { return false; } } int lock(int val, int minv, int maxv) { return min(max(val, minv), maxv); } void mousePressed() { if (overRect(0,0,400,400)) // Reset if user clicks on the seeker field. { newGoldMines(); newHome(); resetSeekers(); } else if (overRect(400,305,600,400)) { refresh = !refresh; } }