I have to create a small 2D Java tile game for schoolwork and I would like to know how can I move an object with the press of a button.
More specifically, I have an item with ' i ' and ' j ' coordinates in a matrix. After I press ENTER on my keyboard, I want the item to move down by 1 position ( i + 1). If I press ENTER over and over again, the object moves down accordingly. As if the game would be 1 frame/second. How can I do that? I'm kind of new to the Java language and I couldn't find the answer online.
(To make the game with GUI, I followed some tutorials and I'm using the Slick2D library.)