// Koipond 1.0 // // The fish runs away from the mouse. // Use this to guide it towards good, green food... // ... and away from harmful red food. // // Sarah Gould // 28 May 2007 // // Some rights reserved: // http://creativecommons.org/licenses/by-nc-sa/3.0/ // *********** // // General setup int fieldSize = 300; color backgroundColor = color(0, 0, 51); PFont font; // Fish setup float x = fieldSize/2; float y = fieldSize/2; float bigness = 20; float speed = .75; float turnSpeed = 1; float angle = 0; float goalAngle = 0; float sensitivity = 100; // Ripples setup int ripples = 10; float ripplesX[] = new float[ripples]; float ripplesY[] = new float[ripples]; float ripplesSize[] = new float[ripples]; float maxRippleSize = 100; float rippleSpeed = .6; // Food-eaten bubble setup boolean burstExists = false; float burstX; float burstY; float burstSize = 0; float maxBurstSize = 100; float burstSpeed = 3; color burstColor; // Foods setup int foods = 1; int goodFoods = 0; int maxFoods = 255; float foodsX[] = new float[maxFoods]; float foodsY[] = new float[maxFoods]; int foodsType[] = new int[maxFoods]; float foodsSize = 7; float percentBad = .4; int score = 0; int bonus = 1; void setup() { size(fieldSize, fieldSize); smooth(); // Load the font font = loadFont("Ziggurat-HTF-Black-32.vlw"); textFont(font, 24); // Initialize the foods for(int i=0; i fieldSize) { x = 0; } if(y > fieldSize) { y = 0; } } void drawKoi() { noStroke(); fill(255, 200, 50); // Draw the torpedo body float segments = 6; float adjustedBigness = bigness/segments; for(float i=0; i= 1)) { foodsType[i] = 1; } else { foodsType[i] = 0; goodFoods++; } } void foodBurst() { // Draw the food burst, increasing in size and decreasing in opacity noStroke(); fill(burstColor, 200 - (burstSize * 200/maxBurstSize)); burstSize = burstSize + burstSpeed; ellipse(burstX, burstY, burstSize, burstSize); if(burstSize > maxBurstSize) { burstExists = false; } } void ripples() { // Draw each ripple bigger and more transparent, and add a new one at the mouse strokeWeight(2); noFill(); for(int i=0; i maxRippleSize/ripples) { for(int i=1; i