title: 2D Game paradigm
body: <p>I am trying to broaden by OOP skills by trying to program a 2D graphical game. Using Java's swing utilities.</p>
  
  <p>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).</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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".</p>
  
  <p>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.</p>
  
  <p>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?</p>
  
  <p>--- EDIT*</p>
  
  <p>Here are all the source files as requested.
  <a href="https://www.dropbox.com/sh/f4diy7qtzh4xkem/AABUkM415PrRK1hu35TVkBo2a" rel="nofollow">https://www.dropbox.com/sh/f4diy7qtzh4xkem/AABUkM415PrRK1hu35TVkBo2a</a></p>
  
  <p>General classes: Main, Window, GameState, Robot.
  Interfaces: Movement
  Abstracts: GameVisualiser
  Listeners: ArrowPress</p>
  
  <p>Forgive some of the commenting.</p>