Package com.artemis

Examples of com.artemis.Entity


      float offsetY = cameraSystem.getStartY();
      g.drawRect(offsetX*scaleX, offsetY*scaleY, scaleX*cameraSystem.getWidth(), scaleY*cameraSystem.getHeight());
     
      ImmutableBag<Entity> entities = world.getManager(GroupManager.class).getEntities("crates");
      for(int i = 0; entities.size() > i; i++) {
        Entity crate = entities.get(i);
        Physics cratePhysics = physicsMapper.get(crate);
        float crateX = cratePhysics.getX()*scaleX;
        float crateY = cratePhysics.getY()*scaleY;
        g.fillRect(crateX-1, crateY-1, 2, 2);
      }
     
      ImmutableBag<Entity> tanks = world.getManager(GroupManager.class).getEntities("tanks");
      for(int i = 0; tanks.size() > i; i++) {
        Entity t = tanks.get(i);
        String tp = world.getManager(PlayerManager.class).getPlayer(t);
        Physics physics = physicsMapper.get(t);
        g.setColor(Color.green);
        float tx = physics.getX()*scaleX;
        float ty = physics.getY()*scaleY;
 
View Full Code Here


  @Override
  public void collisionOccured(CollisionEvent event) {
    Body bodyA = event.getBodyA();
    Body bodyB = event.getBodyB();

    Entity entityA = Entity.class.cast(bodyA.getUserData());
    Entity entityB = Entity.class.cast(bodyB.getUserData());

    ImmutableBag<String> groupsA = world.getManager(GroupManager.class).getGroups(entityA);
    ImmutableBag<String> groupsB = world.getManager(GroupManager.class).getGroups(entityB);
   
    if(groupsA.contains("crates") && groupsB.contains("bullets")) {
View Full Code Here

  protected final void processEntities(ImmutableBag<Entity> entities) {
    delay = Float.MAX_VALUE;
    Object[] array = ((Bag<Entity>)entities).getData();
    int processed = entities.size();
    for (int i = 0; processed > i; i++) {
      Entity entity = (Entity)array[i];
      processDelta(entity, acc);
      float remaining = getRemainingDelay(entity);
      if(remaining <= 0) {
        processExpired(entity);
      } else {
View Full Code Here

    world = new World();
    world.setSystem(new EntitySystemA());
    world.setSystem(new EntitySystemB());
    world.initialize();
   
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
   
    EntityEdit edit1 = e1.edit();
    EntityEdit edit2 = e2.edit();
    initComponent(edit1.create(StructComponentA.class));
    initComponent(edit1.create(Position.class));
    initComponent(edit2.create(StructComponentA.class));
    initComponent(edit2.create(Position.class));
  }
View Full Code Here

  @Test @SuppressWarnings("static-method")
  public void empty_packed_shouldnt_reference_bytbuffer() throws Exception {
    World world = new World();
    world.initialize();
   
    Entity e1 = world.createEntity();
    EmptyPacked empty = e1.createComponent(EmptyPacked.class);
    assertEquals(PackedComponent.class, empty.getClass().getSuperclass());
  }
View Full Code Here

 
  @Test
  public void test_primitive_fields_are_reset() {
    assertEquals(PooledComponent.class, PooledPosition.class.getSuperclass());
   
    Entity e = world.createEntity();
    PooledPosition c = createPosition(e);
   
    world.process();
    e.deleteFromWorld();
    world.process();
   
    Entity e2 = world.createEntity();
    PooledPosition c2 = createPosition(e);
   
    assertTrue(c == c2);
  }
View Full Code Here

  @Test
  public void test_complex_fields_are_not_nulled() {
    Assert.assertEquals(PooledComponent.class, PooledObjectPosition.class.getSuperclass());
   
    Entity e = world.createEntity();
    PooledObjectPosition c = e.createComponent(PooledObjectPosition.class);
    assertEquals(0, c.vec2.x, 0.0001f);
    assertEquals(0, c.vec2.x, 0.0001f);
   
    c.vec2.x = 2;
    c.vec2.y = 3;
   
    world.process();
    e.deleteFromWorld();
    world.process();
   
    Entity e2 = world.createEntity();
    PooledObjectPosition c2 = e2.createComponent(PooledObjectPosition.class);
    assertEquals(2, c.vec2.x, 0.0001f);
    assertEquals(3, c.vec2.y, 0.0001f);
   
    assertTrue(c == c2);
  }
View Full Code Here

  @Test @SuppressWarnings("static-method")
  public void pooled_class_transformation() throws Exception {
    World world = new World();
    world.initialize();
   
    Entity e = world.createEntity();
    PooledAllFields pooled = e.createComponent(PooledAllFields.class);
    assertEquals(PooledComponent.class, pooled.getClass().getSuperclass());
   
    Method reset = pooled.getClass().getMethod("reset");
    reset.setAccessible(true);
    reset.invoke(pooled);
View Full Code Here

    world.initialize();
   
    for (int i = 0; 2048 > i; i++)
      createEntity(world);
   
    Entity last = createEntity(world);
    last.createComponent(SimpleComponent.class).set(420);
   
    world.process();
   
    SimpleComponent component = last.getComponent(SimpleComponent.class);
    assertNotNull(component);
    assertEquals(420, component.get());
    assertCapacity(128 * 8, component);
  }
View Full Code Here

    assertEquals(420, component.get());
    assertCapacity(128 * 8, component);
  }

  private static Entity createEntity(World w) {
    Entity e = w.createEntity();
    e.addToWorld();
    return e;
  }
View Full Code Here

TOP

Related Classes of com.artemis.Entity

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.