Sorry to revive a slightly old thread, but I have been following the same tutorials and face the same issue.
I too would like to be able to rotate the sprite left or right by holding down A or D, but so far, I haven't had much success in trying to get it to work.
I have made 2 boolean variables called AisPressed and DisPressed, setting them with default values of false.
I have 2 getter methods inside of the InputHandler class which return the value of AisPressed or DisPressed.
When an either A or D is pressed, it changes the boolean value of AisPressed or DisPressed to true. When the key is lifted, it changes to false again.
I have code inside of the Ship.update method which asks:
rotation = velocity.angle() - 1;
rotation = velocity.angle() + 1;
However, I believe my problem is that the World.update method runs, and inside that method, the ship.update method runs before the program gets the user input, so the variable AisPressed or DisPressed is non existent just yet, therefore I get an exception error.
I have run into this issue before and have forgotten how I got around it, I am having a gigantic mental blank, so any help would be appreciated
(PS: I feel like a dummy right now