use of com.gemserk.commons.artemis.components.MovementComponent in project commons-gdx by gemserk.
the class MovementSystem method processEntities.
@Override
protected void processEntities() {
RandomAccessMap<Entity, EntityComponents> allTheEntityComponents = componentsHolder.entityComponents;
int entitiesSize = allTheEntityComponents.size();
float delta = GlobalTime.getDelta();
for (int entityIndex = 0; entityIndex < entitiesSize; entityIndex++) {
EntityComponents entityComponents = allTheEntityComponents.get(entityIndex);
MovementComponent movementComponent = entityComponents.movementComponent;
Spatial spatial = entityComponents.spatialComponent.getSpatial();
Vector2 velocity = movementComponent.getVelocity();
tmpVelocity.set(velocity).mul(delta);
tmpPosition.set(spatial.getX(), spatial.getY()).add(tmpVelocity);
float newAngle = spatial.getAngle() + delta * movementComponent.getAngularVelocity();
spatial.setAngle(newAngle);
spatial.setPosition(tmpPosition.x, tmpPosition.y);
}
}
Aggregations