import java.applet.*; import java.awt.*; import java.awt.image.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.text.*; import java.util.*; import java.util.zip.*; public class levitatedTentacle15 extends BApplet { // Set the font and its size (in units of pixels) int xWidth = 800, yHeight = 500; int total = 0; Tentacle[] tentacle = new Tentacle[1500]; boolean clear = true; boolean click = false; int counter = 0; void setup() { for (int i=0; i= 1500){ total = 1500; } else { total = total + 1; } } void drawState(){ if (clear){ fill(0); noStroke(); rect(0,0,width,height); } } void keyReleased () { if (key == ' ' && clear) { clear = false; } else if (key == ' ' && !clear) { clear = true; } } class Tentacle { int numNodes = 50; float head = 1; float girth = 3; float baseSpeed = random(0.8f,0.99f); float speedCoefficient; float friction = .99f; float muscleRange = 45; float muscleFreq = .3f; float theta; float thetaMuscle; float count = 0; float xPos, yPos; float tv; float angle, mAngle, m2Angle; float xOffset = width/2; float yOffset = height/2; float tvVar; float tvRange = random(3,8); float dx, dy, d; SnakeHead[] node = new SnakeHead[numNodes]; Tentacle () { } void move () { if(count == 0){ xPos = mouseX; yPos = mouseY; for (int n=0; n 0){ node[n].setX(((pmouseX - mouseX)*(n/numNodes)) + mouseX); node[n].setY(((pmouseY - mouseY)*(n/numNodes)) + mouseY); } else { node[n].setX(mouseX); node[n].setY(mouseY); } } angle = atan2((mouseY-pmouseY), (mouseX-pmouseX)); theta = angle * (180/PI); } mAngle = atan2((mouseY-node[0].getY()), (mouseX-node[0].getX())); mAngle = mAngle * (180/PI); m2Angle = atan2((node[0].getY()-node[1].getY()), (node[0].getX()-node[1].getX())); m2Angle = m2Angle * (180/PI); dx = mouseX - node[0].getX(); dy = mouseY - node[0].getY(); d = sqrt(sq(dx) + sq(dy)); speedCoefficient = baseSpeed - d / 2000; //System.out.println("mAngle = " + mAngle + " and m2Angle = " + m2Angle); if (mAngle > m2Angle){ tvVar = random(0,tvRange); } else if (mAngle < m2Angle){ tvVar = random(-tvRange,0); } tv = tv + tvVar; theta = theta + tv; tv = tv * friction; if (node[0].getX() > width*4){ xPos = xPos - (width*5); for (int n=0; n height*4){ yPos = yPos - (height*5); for (int n=0; n500) || (yPos<100) || (yPos>500)){ // destroy(); //} } } // strokeWidth(1); for (int i=2; i