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 (290)
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  
  [Game Thread, when to update FPS?] *solved*  (Read 238 times)
0 Members and 1 Guest are viewing this topic.
Offline GabrielBailey74

JGO Knight


Medals: 8
Projects: 6


<3 Java


« Posted 2013-01-12 04:38:18 »

Hello JGO Pointing
Today I've been constructing a Game Loop so that I can calculate some statistics of it and such Cool

Information:
The Game Loop is a thread.

Game run method layout:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
public void run() {
   /* Initialize Starting Times */
   while (!isDestroyed()) {
      /* Update Game Logic */
      update();
      /* Render */
      render();
      /* Send the thread to sleep ^_^, no calculations for it at the moment */
      sleep(10L, true);
      /* Calculate some statistics */
      debug();
   }
}


My Question is:
Where in my game thread would I call the 'updateFPS()' method?
Before sleeping?, before painting?, after painting?
I've never known this lol, and now that I'm constructing a good game thread I'd like to ^__^.

Any feedback would be helpful thanks Cheesy

Online Agro
« Reply #1 - Posted 2013-01-12 05:19:29 »

Generally at the end of the loop, because it makes more sense. If you do everything, calculate the FPS, and do everything again, and calculate it again, it will keep a hopefully constant rate. Also, you would want to do it at the end because you'll know how many frames of all the updating and rendering in a second.

Offline GabrielBailey74

JGO Knight


Medals: 8
Projects: 6


<3 Java


« Reply #2 - Posted 2013-01-13 22:58:12 »

Well thanks ago ^__^.
I always inserted the method to update @ the beginning Emo

Pages: [1]
  ignore  |  Print  
 
 

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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 (66 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (178 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.08 seconds with 20 queries.