package lilWorld; import processing.core.PApplet; import processing.core.PVector; import java.util.ArrayList; import java.util.List; public class Drifter extends Creature{ float earMultiplier = (float)Math.random(); public Drifter(PVector l, PVector a, PVector v, int m_, PApplet p) { super(l, a, v, m_, p); grav = new PVector(0,-.002f); } public void move() { applyForce(grav); float randomY = (float) Math.random(); PVector wind = new PVector(0.005f,-randomY/10); //applyForce(wind); // applyForce(. . .); if((loc.x <= 3) || (loc.x >= parent.width-3)) { vel.x = -vel.x/2; //pure bounce } if ((loc.y <= 3) || (loc.y >= parent.height-3)) { vel.y = -vel.y; //pure bounce } vel.add(acc); 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() { //System.out.println("here drifter"); parent.fill(200,200,200); parent.noStroke(); if(getChangeColor()) { parent.fill(0,0,255,170); } else { parent.fill(255, 255, 255, 170); } parent.pushMatrix(); parent.translate(loc.x,loc.y); //parent.rotate(vel.heading2D()/parent.random(25,75)); parent.rotate(vel.heading2D()); 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); } }