Examples of PositionComponent


Examples of com.badlogic.ashley.benchmark.artemis.components.PositionComponent

   
    for (int i = 0; i < numEntities; ++i) {
      Entity entity = world.createEntity();
     
      if (Constants.shouldHaveComponent(ComponentType.POSITION, i)) {
        PositionComponent pos = new PositionComponent();
        pos.pos.x = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
        pos.pos.y = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
        entity.addComponent(pos);
      }
     
View Full Code Here

Examples of com.badlogic.ashley.benchmark.artemis.components.PositionComponent

    mm = world.getMapper(MovementComponent.class);
  };
 
  @Override
  protected void process(Entity entity) {
    PositionComponent pos = pm.get(entity);
    MovementComponent mov = mm.get(entity);
   
    tmp.set(mov.accel).scl(world.getDelta());
    mov.velocity.add(tmp);
   
View Full Code Here

Examples of com.badlogic.ashley.benchmark.ashley.components.PositionComponent

   
    for (int i = 0; i < numEntities; ++i) {
      Entity entity = new Entity();
     
      if (Constants.shouldHaveComponent(ComponentType.POSITION, i)) {
        PositionComponent pos = new PositionComponent();
        pos.pos.x = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
        pos.pos.y = MathUtils.random(Constants.MIN_POS, Constants.MAX_POS);
        entity.add(pos);
      }
     
View Full Code Here

Examples of com.badlogic.ashley.benchmark.ashley.components.PositionComponent

    super(Family.getFor(PositionComponent.class, MovementComponent.class));
  }

  @Override
  public void processEntity(Entity entity, float deltaTime) {
    PositionComponent pos = pm.get(entity);
    MovementComponent mov = mm.get(entity);
   
    tmp.set(mov.accel).scl(deltaTime);
    mov.velocity.add(tmp);
   
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

  }

  @Override
  public void update(float deltaTime) {
    PositionComponent position;
    VisualComponent visual;
   
    camera.update();
   
    batch.begin();
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

    super(Family.getFor(PositionComponent.class, MovementComponent.class));
  }

  @Override
  public void processEntity(Entity entity, float deltaTime) {
    PositionComponent position = pm.get(entity);
    MovementComponent movement = mm.get(entity);
   
    position.x += movement.velocityX * deltaTime;
    position.y += movement.velocityY * deltaTime;
  }
 
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

    Listener listener = new Listener();
    engine.addEntityListener(listener);
   
    for(int i=0; i<10; i++){
      Entity entity = engine.createEntity();
      entity.add(new PositionComponent(10, 0));
      if(i > 5)
        entity.add(new MovementComponent(10, 2));
     
      engine.addEntity(entity);
    }
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

    public void update(float deltaTime) {
     
      for (int i = 0; i < entities.size(); ++i){
        Entity e = entities.get(i);
       
        PositionComponent p = pm.get(e);
        MovementComponent m = mm.get(e);
       
        p.x += m.velocityX * deltaTime;
        p.y += m.velocityY * deltaTime;
      }
 
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

   
    for(int i=0; i<NUMBER_ENTITIES; i++){
      Entity entity = engine.createEntity();
     
      entity.add(new MovementComponent(10, 10));
      entity.add(new PositionComponent(0, 0));
     
      engine.addEntity(entity);
     
      entities.add(entity);
    }
   
    System.out.println("Entities added time: " + timer.stop("entities") + "ms");
   
    /** Removing components */
    timer.start("componentRemoved");
   
    for(Entity e:entities){
      e.remove(PositionComponent.class);
    }
   
    System.out.println("Component removed time: " + timer.stop("componentRemoved") + "ms");
   
    /** Adding components */
    timer.start("componentAdded");
   
    for(Entity e:entities){
      e.add(new PositionComponent(0, 0));
    }
   
    System.out.println("Component added time: " + timer.stop("componentAdded") + "ms");
   
    /** System processing */
 
View Full Code Here

Examples of com.badlogic.ashley.tests.components.PositionComponent

      engine = new PooledEngine();
      engine.addSystem(new RenderSystem(camera));
      engine.addSystem(new MovementSystem());
     
      Entity crate = engine.createEntity();
      crate.add(new PositionComponent(50, 50));
      crate.add(new VisualComponent(new TextureRegion(crateTexture)));

      engine.addEntity(crate);
     
      TextureRegion coinRegion = new TextureRegion(coinTexture);
     
      for(int i=0; i<100; i++){
        Entity coin = engine.createEntity();
        coin.add(new PositionComponent(MathUtils.random(640), MathUtils.random(480)));
        coin.add(new MovementComponent(10.0f, 10.0f));
        coin.add(new VisualComponent(coinRegion));
        engine.addEntity(coin);
      }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.