package uk.co.flyingsquirrels.models; import org.jbox2d.common.Vec2; public class Engine extends ControllableComponentTemplate { private final float maxThrust; private final Vec2 thrustLine; private Vec2 thrust = new Vec2(0, 0); public Engine(float maxThrust, Vec2 thrustLine, Vec2 localPosition) { super(localPosition, new Control()); this.maxThrust = maxThrust; thrustLine.normalize(); this.thrustLine = thrustLine; } public void updateInternal(float seconds) { thrust = thrustLine.mul(getControl().getValue() * maxThrust); } public Vec2 getForce() { return thrust; } }