So I'm making a sort of space game in Java. Currently, the spacecraft stays in place if the user isn't doing anything, and moves at a constant velocity in different directions based on the user's key input.
I'd like to change it so that when the spacecraft is moving, as the user continues to press the key, the spacecraft's velocity accelerates faster.
In my move method, I currently have
public void move() {
x += dx;
y += dy;
}
I've tried doing such things as
public void move() {
x *= dx;
y *= dy;
}
But constantly multiplying values makes the spacecraft move way too fast.
Is there another approach to doing this?
Thanks in advance.