Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (756)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  If java3d's timer is deprecated, what should be used in it's place?  (Read 3606 times)
0 Members and 1 Guest are viewing this topic.
Offline dah01

Junior Devvie

Medals: 7

« Posted 2011-03-07 23:48:14 »

I'm finding it amazingly difficult to start java game dev. Every book has a different idea of optimum and I can't figure out which book I should follow.

Offline lhkbob

JGO Knight

Medals: 32

« Reply #1 - Posted 2011-03-08 00:31:52 »

System.nanoTime() or System.currentTimeMillis() have been vastly improved from the errors and problems most likely presented in the books you've read.  Especially for starting, they are the best.  If you're using LWJGL, they have a good timer as well, but if you can't start java game dev then LWJGL is not something you should look into yet (but remember that it exists for when you get more comfortable programming).

Offline dah01

Junior Devvie

Medals: 7

« Reply #2 - Posted 2011-03-08 00:56:03 »

Thanks for your response. Can you give me an example animation loop using either of these?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline BatKid

Senior Newbie

« Reply #3 - Posted 2011-03-08 02:31:18 »

I think it depends on what you kind of games you want to create?  Do you want 2D or 3D?  Hardware accelerated or not?  Puzzle or action?  Network?

Each of the above decision will affect how you create your game.  For example, if you want a simple 2D applet game, you will want to use the swing Canvas class and use the Graphics class to draw and paint stuff on screen.  If you want OpenGL hardware accelerated games, you'll want to look at OpenGL bindings like LWJGL or JOGL.  If you want hardware accelerated but don't want to deal with low-level OpenGL calls, you'll want to look at game engines such as Slick (for 2D), and JavaMonkeyEngine or JPCT (for 3D).

There are so many choices that it is very easy to get confused when you are just learning the basics of game programming.  Since I teach java programming and I have an interest in 3D accelerated games, I have created my own framework specifically to make it easy to learn the ins and outs of programming concepts in a gaming context.  You can find the tutorials at  The lessons are very easy to follow especially if you are a professional Java programmer.

Good luck and have lots of fun!

Learn Java in 3D with env3d
Offline dah01

Junior Devvie

Medals: 7

« Reply #4 - Posted 2011-03-08 12:45:52 »

I'd like to develop 2d sidescrollers, puzzle games, 2d tactics games.
Offline lhkbob

JGO Knight

Medals: 32

« Reply #5 - Posted 2011-03-08 14:32:16 »

Here is the simplest loop. Perhaps not the greatest, but will be sufficient for early games:
public static final int FRAMERATE = 30;

public static void main(String[] args) throws InterruptedException {
   long millisDelay = 1000 / FRAMERATE;

   // ... setup game here

   while(!quitRequested) {
      long now = System.currentTimeMillis();
      // ... run game logic every frame

      long remaining = millisDelay - (System.currentTimeMillis() - now);
      if (remaining > 0)

   // ... clean up game here

But I haven't tested it and I've written just I as I woke up so please experiment with it and feel free to change it if you need to make something better.

Pages: [1]
  ignore  |  Print  

DesertCoockie (52 views)
2018-05-13 18:23:11

nelsongames (83 views)
2018-04-24 18:15:36

nelsongames (74 views)
2018-04-24 18:14:32

ivj94 (759 views)
2018-03-24 14:47:39

ivj94 (87 views)
2018-03-24 14:46:31

ivj94 (643 views)
2018-03-24 14:43:53

Solater (102 views)
2018-03-17 05:04:08

nelsongames (184 views)
2018-03-05 17:56:34

Gornova (426 views)
2018-03-02 22:15:33

buddyBro (1086 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!