当前位置: 首页>>代码示例>>Java>>正文


Java MovementComponent类代码示例

本文整理汇总了Java中com.badlogic.ashley.benchmark.artemis.components.MovementComponent的典型用法代码示例。如果您正苦于以下问题:Java MovementComponent类的具体用法?Java MovementComponent怎么用?Java MovementComponent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MovementComponent类属于com.badlogic.ashley.benchmark.artemis.components包,在下文中一共展示了MovementComponent类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
@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);

	tmp.set(mov.velocity).scl(world.getDelta());
	pos.pos.add(tmp.x, tmp.y, 0.0f);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:12,代码来源:MovementSystem.java

示例2: process

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
@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);

    tmp.set(mov.velocity).scl(world.getDelta());
    pos.pos.add(tmp.x, tmp.y, 0.0f);
}
 
开发者ID:grum,项目名称:Ashley,代码行数:12,代码来源:MovementSystem.java

示例3: prepareWorld

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
private static World prepareWorld (int numEntities) {
	World world = new World();

	world.setSystem(new MovementSystem());
	world.setSystem(new StateSystem());
	world.setSystem(new CollisionSystem());
	world.setSystem(new RemovalSystem());

	world.initialize();

	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);
		}

		if (Constants.shouldHaveComponent(ComponentType.MOVEMENT, i)) {
			MovementComponent mov = new MovementComponent();
			mov.velocity.x = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
			mov.velocity.y = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
			mov.accel.x = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);
			mov.accel.y = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);

			entity.addComponent(mov);
		}

		if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
			RadiusComponent rad = new RadiusComponent();
			rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
			entity.addComponent(rad);
		}

		if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
			entity.addComponent(new StateComponent());
		}

		world.addEntity(entity);
	}

	return world;
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:46,代码来源:ArtemisBenchmark.java

示例4: MovementSystem

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
public MovementSystem () {
	super(Aspect.getAspectForAll(PositionComponent.class, MovementComponent.class));
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:4,代码来源:MovementSystem.java

示例5: initialize

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
@Override
protected void initialize () {
	pm = world.getMapper(PositionComponent.class);
	mm = world.getMapper(MovementComponent.class);
}
 
开发者ID:DevelopersGuild,项目名称:Planetbase,代码行数:6,代码来源:MovementSystem.java

示例6: prepareWorld

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
private static World prepareWorld(int numEntities) {
    World world = new World();

    world.setSystem(new MovementSystem());
    world.setSystem(new StateSystem());
    world.setSystem(new CollisionSystem());
    world.setSystem(new RemovalSystem());

    world.initialize();

    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);
        }

        if (Constants.shouldHaveComponent(ComponentType.MOVEMENT, i)) {
            MovementComponent mov = new MovementComponent();
            mov.velocity.x = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
            mov.velocity.y = MathUtils.random(Constants.MIN_VEL, Constants.MAX_VEL);
            mov.accel.x = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);
            mov.accel.y = MathUtils.random(Constants.MIN_ACC, Constants.MAX_ACC);

            entity.addComponent(mov);
        }

        if (Constants.shouldHaveComponent(ComponentType.RADIUS, i)) {
            RadiusComponent rad = new RadiusComponent();
            rad.radius = MathUtils.random(Constants.MIN_RADIUS, Constants.MAX_RADIUS);
            entity.addComponent(rad);
        }

        if (Constants.shouldHaveComponent(ComponentType.STATE, i)) {
            entity.addComponent(new StateComponent());
        }

        world.addEntity(entity);
    }

    return world;
}
 
开发者ID:grum,项目名称:Ashley,代码行数:46,代码来源:ArtemisBenchmark.java

示例7: MovementSystem

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
public MovementSystem() {
    super(Aspect.getAspectForAll(PositionComponent.class, MovementComponent.class));
}
 
开发者ID:grum,项目名称:Ashley,代码行数:4,代码来源:MovementSystem.java

示例8: initialize

import com.badlogic.ashley.benchmark.artemis.components.MovementComponent; //导入依赖的package包/类
@Override
protected void initialize() {
    pm = world.getMapper(PositionComponent.class);
    mm = world.getMapper(MovementComponent.class);
}
 
开发者ID:grum,项目名称:Ashley,代码行数:6,代码来源:MovementSystem.java


注:本文中的com.badlogic.ashley.benchmark.artemis.components.MovementComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。