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 (404)
games submitted by our members
Games in WIP (289)
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  
  Regarding Frame Rate  (Read 276 times)
0 Members and 1 Guest are viewing this topic.
Online Agro
« Posted 2013-01-26 02:21:27 »

I've really been looking into frame rate in my games for some time, and now its really bugging me. I've been doing many different methods of keeping frame rate, and I can't find a single one that is effective and precise. This is the one I'm using right now:

http://pastie.org/private/vows8sgvcrkeuixsgvj3g

I've also noticed that when entities disappear from the screen(they're still being updated and rendered, just not visible to you), the consistency of the frame rate starts improving.

So, I'm looking for a few things here:

1. What is the best way to handle frame rate?
2. A good way to handle and store entities. I use an ArrayList and I just loop through them two times to render and update.

Its been really bugging me for awhile, especially when there are about 50 entities on the screen.

Please help D:

Offline Best Username Ever

Junior Member





« Reply #1 - Posted 2013-01-26 06:18:07 »

That's lag. You are taking to long to draw things sometimes. Changing the game loop won't help.
Offline Ultroman

JGO Knight


Medals: 23
Projects: 1


Snappin' at snizzes since '83


« Reply #2 - Posted 2013-01-26 07:00:49 »

For calculating framerate and running a gameloop, this is what I use. Works wonders for me. It was written for Java2D, which I'm assuming you're using due to your problem-description.

Hope it helps.

And if your entities are still being updated and rendered when they're not visible, you should probably do something about that. I don't do a draw-call on entities that are not on the screen, and if they're more than 200px outside the screen, I don't even run update(deltaTime) on them. Saves a lot in a big world.

- Jonas
Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline philfrei
« Reply #3 - Posted 2013-01-26 11:26:54 »

You might consider making the game loop a util.Timer. You can specify the exact repeating time interval as a parameter. But if you take too long to render, the timing will be thrown, just as it is in a game loop.

Some folks don't like Timers, and the swing.Timer is very problematic as the EDT gets clogged up pretty quickly. But "Killer Game Programming" seems to demonstrate that a util.Timer is a reasonable option, even if it isn't their first choice. I don't know why more people don't use them. Fear of multithreading? That seems misplaced to me, since a new thread isn't launched until the previous one completes.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
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 (34 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (148 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.075 seconds with 21 queries.