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   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: lwjgl getTime and it's delta issue on: 2014-01-07 17:29:23
honestly i thought about it but:

1) i'd really like to know why it's behaving the way it is and
2) his link in the video's comments shows the code also as completed (for the whole video)

i'd like to be able to work through the video as a whole to get a better understanding on how this part works.

another option would be to try coding the example again >.<
2  Game Development / Newbie & Debugging Questions / lwjgl getTime and it's delta issue on: 2014-01-07 17:09:43
I've been following a youtube tutorial(The Coding Universe) for LWJGL and everything's been working fine up until the section on timers.

I copied it directly as he was saying but when i did System.out.println(getDelta());

it's returning not only extremly large numbers there are also negatives!

Quote
-46529436
-1408005007
1916619492
946277273
-219630599
-1189971696
2134655081
968748809
-1590588
-971929407
-2137834079
1186795520
216458401
-949444671
-1919780668
1404851209
238949737
-731384560
-1701718279
1427349145
457016548

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
   private long getTime() {
      //returns time in milliseconds
     return (Sys.getTime()* 1000) / (Sys.getTimerResolution());
   }
   
   private int getDelta() {
      long currentTime = getTime();
      int delta = (int)(currentTime * lastFrame);
      lastFrame = getTime();
      return delta;
   }


i get similar results with System.currentTimeMillis() and System.nanoTime()

Quote from: currentTimeMillis()
1389113138376
1389113138393
1389113138409
1389113138426
1389113138443
1389113138459
1389113138476

Quote from: nanoTime()
98300200493549
98300217430225
98300234429621
98300250546376
98300267714546
98300284704819
98300300789074

i wanted to see if it would affect the rest of the code, so i kept going (supposed to use the delta to move a box off the screen) but where you should see the box move off, it doesnt even show up. (or does and gets flung off the screen faster than i can see it?!)

and removing or keeping Display.sync(60); in the code doesnt change anything.

the code he linked in the comments for the example isnt quite the same either (same code pieces but main loop and opengl initialization is placed in the main instead of creating a method and starting it in the main.

working in eclipse on windows 8 pro if that makes any difference...  Sad
Pages: [1]
 

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 (38 views)
2014-09-24 16:13:29

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

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

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

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

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

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

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

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

BurntPizza (53 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!