Ejemplo n.º 1
0
 public void jolt() {
   Random r = new Random();
   Vector v = new Vector(r.nextFloat() - 0.5f, r.nextFloat() - 0.5f, 0);
   v.normalize();
   v.scale(0.1f);
   particle.applyForce(v);
 }
Ejemplo n.º 2
0
  public void explosionAt(float mx, float my, float range, float power) {
    float x = particle.getX();
    float y = particle.getY();

    float dx = x - mx;
    float dy = y - my;

    if (dx == 0) dx += 0.000001f;
    if (dy == 0) dy += 0.000001f;

    float d = dx * dx + dy * dy;

    if (d < range * range) {
      Vector push = new Vector(dx, dy, 0);
      push.normalize();
      push.scale(power * (1 - d / range / range));
      particle.applyForce(push);
    }
  }