Package com.badlogic.ashley.core

Examples of com.badlogic.ashley.core.PooledEngine


import com.badlogic.ashley.utils.ImmutableArray;

public class BasicTest {
 
  public static void main(String[] args){
    PooledEngine engine = new PooledEngine();
   
    MovementSystem movementSystem = new MovementSystem();
    PositionSystem positionSystem = new PositionSystem();
   
    engine.addSystem(movementSystem);
    engine.addSystem(positionSystem);
   
    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);
    }
   
    log("MovementSystem has: " + movementSystem.entities.size() + " entities.");
    log("PositionSystem has: " + positionSystem.entities.size() + " entities.");
   
    for(int i=0; i<10; i++){
      engine.update(0.25f);
     
      if(i > 5)
        engine.removeSystem(movementSystem);
    }
   
    engine.removeEntityListener(listener);
  }
View Full Code Here


import com.badlogic.ashley.core.PooledEngine;

public class IgnoreSystemTest {

    public static void main(String[] args){
        PooledEngine engine = new PooledEngine();

        CounterSystem counter = new CounterSystem();
        IgnoredSystem ignored = new IgnoredSystem();

        engine.addSystem(counter);
        engine.addSystem(ignored);

        for (int i = 0; i < 10; i++) {
            engine.update(0.25f);
        }
    }
View Full Code Here

 
  public static void main(String[] args){
    Timer timer = new Timer();
    Array<Entity> entities = new Array<>();
   
    PooledEngine engine = new PooledEngine();
   
    engine.addSystem(new MovementSystem());
   
    System.out.println("Number of entities: " + NUMBER_ENTITIES);
   
    /** Adding entities */
    timer.start("entities");
   
    entities.ensureCapacity(NUMBER_ENTITIES);
   
    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 */
    timer.start("systemProcessing");
   
    engine.update(0);
   
    System.out.println("System processing times " + timer.stop("systemProcessing") + "ms");
   
    /** Removing entities */
    timer.start("entitiesRemoved");
   
    engine.removeAllEntities();
   
    System.out.println("Entity removed time: " + timer.stop("entitiesRemoved") + "ms");
  }
View Full Code Here

      camera.update();
     
      Texture crateTexture = new Texture("assets/crate.png");
      Texture coinTexture = new Texture("assets/coin.png");
     
      engine = new PooledEngine();
      engine.addSystem(new RenderSystem(camera));
      engine.addSystem(new MovementSystem());
     
      Entity crate = engine.createEntity();
      crate.add(new PositionComponent(50, 50));
View Full Code Here

TOP

Related Classes of com.badlogic.ashley.core.PooledEngine

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.