Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (292)
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  
  Timing  (Read 1485 times)
0 Members and 1 Guest are viewing this topic.
Visa
Guest
« Posted 2003-05-19 10:58:05 »

Hi everybody!

This is my first posting here because I'm a newbie with java.
I've programmed before with C/C++ and used queryPerformanceCounter for timing.
In java I know only System.currentTimeMillis() and I was wondering
if there is any better/faster way than it?
(I haven't found myself)
If java has many ways to do timing, which is the best?
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #1 - Posted 2003-05-19 11:49:01 »

Congratulations, you found one of java's oldest shortcomings.  Smiley
System.currentTimeMillis() is the only way to measure time without any additional packages/libraries.
If you want to use an additional library:
LWJGL, Java3D and GAGE all have a high resolution timer.
Use LWJGL if you are planning to go for max performance 3D graphics and sound using openGL/openAL, use java3D of you want a convenient general purpose 3D scenegraph API or GAGE if you want to create games using the standard java API's.
(The authors will surely correct me if I'm wrong somewhere  Wink)

Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #2 - Posted 2003-05-19 12:01:00 »

There is a hidden hires timer in the 1.4.2beta...

http://www.java-gaming.org/cgi-bin/JGOForums/YaBB.cgi?board=Tuning;action=display;num=1053157119

Well you can't rely on it. It won't stay there for sure but there will be one in the future Smiley

Untill it's official you should do some stuff with the mentioned libs. I like lwjgl most... but it depends on your needs Wink

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Visa
Guest
« Reply #3 - Posted 2003-05-19 13:45:03 »

Thanks both of you

I'm not planning to go 3D yet. Cry (just starting 2D with java)
But I think I'll take a look at the packages.
So where can I get LWJGL and GAGE? Huh
And what kind of libraries they are? Huh
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #4 - Posted 2003-05-19 14:12:21 »

>So where can I get LWJGL and GAGE? Huh

lwjgl:
http://java-game-lib.sourceforge.net

gage:
http://java.dnsalias.com/

>And what kind of libraries they are? Huh

LWJGL is a openGL wrapper, openal (sound) and input - everything you need to make a fast 2d or 3d game. BTW we have a nice lwjgl forum here Wink

GAGE is a lib for handling 2d stuff and sound. It should be easier to use GAGE for your first 2d game (or your first bunch of games Wink).

Both libs are 100% free to use (even for commercial projects) and are written by talented people of this forum Smiley

弾幕 ☆ @mahonnaiseblog
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #5 - Posted 2003-05-19 14:12:39 »

LWJGL: http://java-game-lib.sourceforge.net
GAGE: http://java.dnsalias.com

Disclaimer: I'm the GAGE author. I think you'll like GAGETimer tho. Smiley

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #6 - Posted 2003-05-20 00:46:53 »

How do I use the GAGE timer? what is the animation loop? is it the one at the bottom of the page?

Kommi
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #7 - Posted 2003-05-20 03:34:38 »

Quote
How do I use the GAGE timer? what is the animation loop? is it the one at the bottom of the page?


The timer is very simply that, a timer. It will give you the current time if you ask. The GAGETimer also includes a way to limit the framerate, thus the algorithm at the bottom of the page. You only need to limit the rate if you have VSyncing disabled. Look at the JavaDocs for some good info on how to interface with the class.

Edit: Added link to JavaDocs

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Reply #8 - Posted 2003-05-20 04:44:26 »

Oh I get it. So after importing the API I just instanciate by saying timer = new AvancedTimer() and later can make the timer.sleep(...) calls in my animation loop.
Question, is your timer a native timer?  

Kommi
Offline kevglass
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #9 - Posted 2003-05-20 06:55:29 »

Is the GAGE timer windows only? I only saw a library for windows (.dll) and was just wondering.

Kev

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #10 - Posted 2003-05-20 14:35:07 »

GAGE is fully cross platform. The DLL is specific to Windows to get around Windows' poor timing ability.

Java Game Console Project
Last Journal Entry: 12/17/04
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (67 views)
2013-05-17 21:29:12

alaslipknot (76 views)
2013-05-16 21:24:48

gouessej (109 views)
2013-05-16 00:53:38

gouessej (104 views)
2013-05-16 00:17:58

theagentd (115 views)
2013-05-15 15:01:13

theagentd (104 views)
2013-05-15 15:00:54

StreetDoggy (149 views)
2013-05-14 15:56:26

kutucuk (172 views)
2013-05-12 17:10:36

kutucuk (170 views)
2013-05-12 15:36:09

UnluckyDevil (179 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.137 seconds with 24 queries.