Please note that applying friction to acceleration makes no sense. Apply it to velocity. Acceleration (caused by a force) is immediately zero after it is processed, as the knockback force is instantaneous.
Instead of having an acceleration vector as field(s), I'd do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| class Entity { Vec2 position; Vec2 velocity; float mass; Vec2 force; float drag;
public void tick() { Vec2 acceleration = new Vec2(force).div(mass); force.set(0,0,0); velocity.add(acceleration); position.add(velocity); velocity.mul(1.0f - drag); } } |
Whether this fits in your game logic, is another matter
