Package hype.core.interfaces

Examples of hype.core.interfaces.HDirectable


  @Override
  public void runBehavior(PApplet app) {
    int numTargets = _targets.size();
    Iterator<HDirectable> it = _targets.iterator();
    for(int i=0; i<numTargets; ++i) {
      HDirectable target = it.next();
     
      float rot = target.rotationRad();
      float tx = target.x();
      float ty = target.y();
     
      float goalx = _idleGoalX;
      float goaly = _idleGoalY;
      float goalz = 0;
      HLocatable goal = getGoal(target, app);
      if(goal != null) {
        goalx = goal.x();
        goaly = goal.y();
        goalz = goal.z();
      }
     
      // Get rotation that points towards the goal, plus easing
      float tmp = HMath.xAxisAngle(tx,ty, goalx,goaly) - rot;
      float dRot = _turnEase * (float)
        Math.atan2( Math.sin(tmp), Math.cos(tmp) );
      rot += dRot;
     
      // Add some random twitching to the rotation via perlin noise
      float noise = app.noise(i*numTargets + app.frameCount/8f);
      rot += HMath.map(noise, 0,1, -_twitchRad,_twitchRad);
     
      // Apply the rotation and move to the direction of its rotation
      target.rotationRad(rot);
      target.x(target.x() + (float)Math.cos(rot)*_speed);
      target.y(target.y() + (float)Math.sin(rot)*_speed);
      target.z(goalz);
    }
  }
 
View Full Code Here

TOP

Related Classes of hype.core.interfaces.HDirectable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.