I am trying to broaden by OOP skills by trying to program a 2D graphical game. Using Java's swing utilities.
Now what I have so far is: 4 general classes, an abstract class, an interface and a KeyListener class. (Don't worry it's a very small game at the moment).
Of the 4 general classes, the main class sets up two other classes as objects within it. These two objects are my graphics and my gamestate. Gamestate in turn sets up the last remaining object (player) within it.
The problem I have is that when I initially got it all working so the player could move (via keyPressed) the way input is read from the keyboard meant the player would jerk forward slightly, then run in a continuous motion. This is exactly how if you hold down a letter key on your keyboard a single letter comes up before a string of letters begin to form.
So I thought: "Oh it's so obvious. I should try and tackle this with booleans so that when a key goes down I have 'boolean right = true'. And I'll have some code somewhere going off in a loop with conditional statements for the moving of the player".
This is where I am stuck. Because I cannot figure out how to do get into this loop without 'jamming up' my program. In attempts I have run my program and been treated to nothing. The program hangs because it's in the loop and hasn't brought up the swing window yet. I have a feeling the answer is thread related (implements runnable), but I am in such new territory with this that I want 'a right and good' way to do it.
So I suppose this is a very open ended question to a variety of answers. How would you (have you) tackle this kind of problem?
--- EDIT*
Here are all the source files as requested. https://www.dropbox.com/sh/f4diy7qtzh4xkem/AABUkM415PrRK1hu35TVkBo2a
General classes: Main, Window, GameState, Robot. Interfaces: Movement Abstracts: GameVisualiser Listeners: ArrowPress
Forgive some of the commenting.