DRY
This commit is contained in:
@@ -44,7 +44,7 @@ public class DarkRP2D extends Game {
|
||||
batch = new SpriteBatch();
|
||||
world = new World(new Vector2(0.f,0.f),true);
|
||||
engine = new Engine();
|
||||
engine.addSystem(new RenderSystem());
|
||||
engine.addSystem(new RenderSystem(MS_PER_UPDATE));
|
||||
engine.addSystem(new MovementSystem());
|
||||
engine.addEntityListener(Family.all(TextureComponent.class).get(), 0, new DisposeListener());
|
||||
camera = new OrthographicCamera();
|
||||
|
||||
@@ -25,9 +25,12 @@ import com.darkrp2d.physics.Box2DUtils;
|
||||
public class RenderSystem extends EntitySystem {
|
||||
|
||||
private ImmutableArray<Entity> entities;
|
||||
private float msPerUpdate;
|
||||
|
||||
|
||||
public RenderSystem() {}
|
||||
public RenderSystem(float msPerUpdate) {
|
||||
this.msPerUpdate = msPerUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addedToEngine(Engine engine) {
|
||||
@@ -42,7 +45,7 @@ public class RenderSystem extends EntitySystem {
|
||||
TextureComponent texture = Mappers.textureComponentMapper.get(entity);
|
||||
|
||||
Vector2 vel = physics.body.getLinearVelocity();
|
||||
vel.scl(1.f/60.f);
|
||||
vel.scl(msPerUpdate);
|
||||
vel.scl(delta);
|
||||
|
||||
batch.draw(texture.tex, Box2DUtils.worldToScreen(physics.body.getPosition().x + vel.x) - texture.tex.getWidth() / 2, Box2DUtils.worldToScreen(physics.body.getPosition().y + vel.y) - texture.tex.getHeight()/2);
|
||||
|
||||
Reference in New Issue
Block a user