Java: Moving an object at an angle and changing angle with KeyPress
Ok, so what i want is the rectangle to always be moving, but when you press the left and right arrow is changes the direction by either increasing or decreasing the angle. With this code the sqaure moves as it should in the correct direction, but when i press the keys the direction does not change. import java.awt.*; import java.awt.Color; import javax.swing.Timer; import javax.swing.*; import java.awt.Graphics; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.KeyListener; import java.awt.event.KeyEvent; import java.awt.event.KeyAdapter; public