Esempio n. 1
0
 @Override
 public void draw(Vec2 pos) {
   super.draw(pos);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40. * health / maxHealth, 6), GREEN);
   Graphics2D.drawRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
 }
Esempio n. 2
0
 public void splash(double x, double strength, ParticleEmitter drops) {
   int index = indexOf(x);
   speeds[index] = strength * strength / 500;
   Util.repeat(
       (int) (strength * strength) / 2000,
       () -> {
         Vec2 dir = Vec2.fromPolar(Math.random(), Math.random() * Math.PI);
         drops.particles.add(
             new Particle(
                 new Vec2(x, heights[index]).add(dir), dir.multiply(50 * Math.sqrt(strength))));
       });
 }
Esempio n. 3
0
  protected static Vec2 findMid(String t, Vec2 d) {

    int tl = t.length();
    double h = FONT.getHeight() / 2.0;
    double w = (FONT.getWidth(" ") * tl) / 2.0;
    return d.divide(2).subtract(new Vec2(w, h));
  }
Esempio n. 4
0
  public boolean containsClick(Vec2 click) {

    return click.containedBy(pos.add(dim), pos);
  }