Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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  
  simple question about the Timer  (Read 1041 times)
0 Members and 1 Guest are viewing this topic.
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Posted 2002-12-18 17:52:59 »

I know that this hi res Timer thing has been discussed to death, but please bear with me, I am new to this. The following is just simple code to display the value of the Java3DTimer:

import com.sun.j3d.utils.timer.J3DTimer;
class test
{
     public static void main(String[] args)
     {
           long time;
           time = J3DTimer.getValue();
           System.out.println(time);
     }
}

When I run the code here is the oputput:
5993877065139

My question is what exactly does this number mean? And how can I use this timer to have an accurate frame rate. I have a simple program with an animation loop and the statement  thread.sleep(30)  which is 30ns. Ofcourse this is inaccurate. I was wondering how exactly do I implement the Java3DTimer in my animation loop?

Also what is WakeupOnElapsedTime(30) about? and how is it used?
Any help is greatly appreciated.

Kommi
Offline Captain-Goatse

Junior Member




I suck at teh 2D. XBOX IS BIG LOL!111


« Reply #1 - Posted 2002-12-30 07:09:47 »

First of all, if you haven't modified the thread and are talking about the same thing as me thread.sleep is ms.  1ms is 1000 000 ns. J3D timer gives out ns therefore you have to get the fps you have to use fps = (long) 1000000 /(J3DTimer.getValue() - StartTime)/ (long) Interval;

and starttime is the value you take vefore you execute the loop.

The way you implement it? It is good to use at any place where you use the System.getMillis() thing, because that is very inaccurate even in milliseconds.
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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (63 views)
2014-09-21 02:42:18

BurntPizza (33 views)
2014-09-21 01:30:30

moogie (41 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!