Esempio n. 1
0
  @Override
  protected void initialize() {
    EntityEdit swarm = world.createEntity().edit();
    swarm.create(Swarm.class);
    swarm.create(Bounds.class).setRadius(10);
    swarm.create(Pos.class);
    swarmId = swarm.getEntityId();
    // we can do about 10k in gwt
    createSwarm(100);
    // hmm consume speed/dmg taken based on swarm size && scale?
    // spread out swarm takes less dmg, but eats slowly,
    // compact swarms eats fast, but is vulnerable to dmg

    edibles =
        world.getAspectSubscriptionManager().get(Aspect.all(Pos.class, Edible.class, Bounds.class));
  }
Esempio n. 2
0
 private void createSwarmer() {
   EntityEdit e = world.createEntity().edit();
   float angSpeed = MathUtils.randomTriangular(15, 180, 45);
   Swarmer swarmer = e.create(Swarmer.class);
   swarmer.setAngle(MathUtils.random(360)).setAngularSpeed(angSpeed);
   swarmer.dst = (swarmer.angularSpeed - 15) / 180;
   swarmer.clamp = MathUtils.clamp(swarmer.dst + MathUtils.random(-.1f, .1f), 0, 1);
   e.create(Tint.class).set(1, 1 - swarmer.clamp, 0, 1);
   e.create(Pos.class).set(cs.xy);
   e.create(Renderable.class).layer = 1;
   Anim anim = e.create(Anim.class);
   anim.id = "one";
   anim.age = MathUtils.random();
   e.create(Scale.class).scale = MathUtils.random(.25f, 1.25f);
   swarmSize++;
 }