package lilWorld; import processing.core.PApplet; import processing.core.PImage; import processing.core.PVector; import java.util.ArrayList; import java.util.List; public class Drifter extends Creature{ float earMultiplier = (float)Math.random(); float rotateAngle = parent.random(0,20); int alphaFill = 100; boolean hasEaten = true; boolean babyTime = true; static List graphics; int graphicsNum; PImage drifty; float timeToBeEaten = 200; float endOfTimeToBeEaten= 20000; float endOfMatingTime =50000; public Drifter(PVector l, PVector a, PVector v, float m_, PApplet p) { super(l, a, v, m_, p); lifespan = new Timer((int) parent.random(20000, 120000)); lifespan.start(); } public void setDrifterSketch() { graphics = new ArrayList(); PImage temp = parent.loadImage("drifter.png"); PImage temp2 = parent.loadImage("drifter2.png"); PImage temp3= parent.loadImage("drifter3.png"); graphics.add(temp); graphics.add(temp2); graphics.add(temp3); } public void move() { grav = new PVector(0,-Vars.drifterGrav); applyForce(grav); float randomY = (float) Math.random(); PVector wind = new PVector(0.005f,-randomY/10); //applyForce(wind); // applyForce(. . .); if((loc.x <= 5) || (loc.x >= parent.width-5)) { vel.x = -vel.x/2; //pure bounce } if ((loc.y <= 5) || (loc.y >= parent.height-5)) { vel.y = -vel.y; //pure bounce } vel.add(acc); //vel.limit(maxspeed); loc.add(vel); acc.mult(0); loc.x = PApplet.constrain(loc.x,0,parent.width-3); loc.y = PApplet.constrain(loc.y,0,parent.height-3); } public void show() { parent.noStroke(); // if(getChangeColor()) // { // if(timer.isFinished()) // { // resetChangeColor(); // parent.fill(255, 255, 255, alphaFill); // // } // else // { // //System.out.println("RED!!!!!!!!!"); // parent.fill(255,255,0, alphaFill); // // } // } // parent.pushMatrix(); // parent.translate(loc.x,loc.y); // parent.rotate(rotateAngle); // //parent.rotate(vel.heading2D()); // //System.out.println(rotateAngle); // parent.ellipse(0,0, size, size); // parent.ellipse(size/3,size/3, (size/2)*(earMultiplier+.5f), (size/2)*(earMultiplier+.5f)); // parent.ellipse(size/3,-size/3, size/3, size/3); // parent.popMatrix(); //parent.stroke(1); parent.pushMatrix(); parent.translate(loc.x,loc.y); parent.rotate(rotateAngle); parent.tint(255,alphaFill); parent.image((PImage)graphics.get(graphicsNum), 0,0, size, size); //parent.ellipse((float) 0+size/2, (float)0+size/2, size, size); parent.popMatrix(); rotateAngle+=parent.random(0,9)*0.001; parent.tint(255,255); } public void grow() { size+=.01; mass = size/2; alphaFill += .25; } public boolean isReady() { if (lifespan.getTime() >700 && lifespan.getTime() timeToBeEaten && lifespan.getTime() < endOfTimeToBeEaten) { return true; } else { return false; } } public boolean noMoreBabies() { if(babyTime) { return false; } else { return true; } } }