Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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 1908 times)
0 Members and 1 Guest are viewing this topic.
Offline dah01

Junior Member


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.

Advice?
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 Member


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 http://env3d.org.  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 Member


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:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
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)
         Thread.sleep(remaining);
   }

   // ... 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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (18 views)
2014-09-19 03:14:18

Dwinin (34 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (84 views)
2014-09-10 06:39:09

Tekkerue (42 views)
2014-09-09 02:24:56

mitcheeb (64 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (39 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org 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‑gaming.org
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!