public class Triangle extends Particle { private float theta; private float rate; /** * Parameterized constructor expects values for position, velocity, acceleration, * and particle size (in that order). */ public Triangle (Vector2D position, Vector2D velocity, Vector2D acceleration, float pWidth, float pHeight) { super(position, velocity, acceleration, pWidth, pHeight); theta = 0; rate = random(-0.1, 0.1); } /** * Method for rendering the triangle: */ public void render () { smooth(); fill(0, 200, 200, 180); //Spinning version: pushMatrix(); translate(position.getX(), position.getY()); rotate(theta); triangle(-pWidth/2, -pHeight/2, pWidth/2, -pHeight/2, -pWidth/2, pHeight/2); theta += rate; popMatrix(); //Non-spinning version: /*triangle(position.getX() - pWidth/2, position.getY() - pHeight/2, position.getX() + pWidth/2, position.getY() - pHeight/2, position.getX() - pWidth/2, position.getY() + pHeight/2);*/ } }