Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It depends on the type of game.</p> <p>For a "fast game" (e.g. a shooter) a dedicate game loop (perhaps in a thread) with a yield/wait (as appropriate) will generally function best. For a "slow games" timers will work just fine -- there are however, <em>two</em> types of Timers:</p> <ol> <li>a "Swing" timer <a href="http://download.oracle.com/javase/tutorial/uiswing/misc/timer.html" rel="nofollow">(javax.swing.Timer)</a> <ol> <li>advantage: runs on the EDT so can touch Swing/AWT objects</li> <li>disadvantage: runs on the EDT so has <em>poor</em> resolution and timing guarantees</li> </ol></li> <li>a "service" timer <a href="http://download.oracle.com/javase/6/docs/api/java/util/Timer.html" rel="nofollow">(java.util.Timer)</a> <ol> <li>advantages: <ol> <li>supports "fixed rate" timer</li> <li>runs on own thread (so resolution/consistency is better, but not guaranteed)</li> </ol></li> <li>disadvantages: does not run on the EDT (so can't touch Swing/AWT).</li> </ol></li> </ol> <p>In <em>many cases</em> the game <em>must still</em> compute the "delta" between when the last event occured and when the current event occurred and use this in calculations. Without a model that uses a delta, game speed will vary between systems.</p> <p>Personally, I would recommend <a href="http://lwjgl.org/" rel="nofollow">LWJGL: Lightweight Java Game Library</a> which offers a high-resolution clock well suited for "fast game" loops. It also supports "direct" OpenGL bindings ;-)</p> <p>I do not have any experience developing "slow games".</p> <p>Happy coding.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload