Game Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesGame Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 16th, 2009, 05:52 PM
Maxh Maxh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2008
Posts: 4 Maxh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 11 m 4 sec
Reputation Power: 0
How to control FPS

I'm working on an Invaders-like game, the problem is I cannot work with the speed of the actors. I have to switch between two computers, a new one and an old one, so in the new one, everything (ie bullets and enemies) moves very quickly (FPS counter shows 200 FPS), while on the old computer, everything moves very slowly (FPS counter shows 60).

I want to control the FPS so I can get a constant 60 FPS. How can I do this?

Edit: I'm programming in Java.

Reply With Quote
  #2  
Old May 17th, 2009, 12:37 PM
Oler1s Oler1s is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jul 2006
Posts: 1,984 Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level)Oler1s User rank is General 2nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 5 Days 9 h 15 m 6 sec
Reputation Power: 1083
Quote:
I want to control the FPS so I can get a constant 60 FPS. How can I do this?
Let me guess, ultimately you have a loop that looks like: while { updateGame() }. And you've discovered that such a naive loop mechanism has the following consequence. The game speed is tied to the computer speed. With no upper bound.

There's no one way, correct way, easy way, or quick way, or whatever to deal with this. You should prepare to do some reading about this topic. A good google term is "timestep" or "time step". Combined that with other related terms like "game" and "fps" and you should get some good articles. Also google for "fix your timestep" which is an article. Some of these articles don't seem relevant, like the fix your timestep article because it very much concerns itself with physics. But spend the time reading it and other articles.

You should eventually pick up on two ideas. The first is that you update the game only every so often. So if your game is clocked to 60 FPS, how many seconds elapse before an update? Or, you update the game as fast as possible. But you scale the updates to match the update speed. Let's say an object is moving at 1 meter/sec at 60 FPS. Your game runs at 100 FPS instead. How much distance should it being per frame in the 100FPS case?
__________________
When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
Want better answers? Tell us what you Googled for and what steps you took to answer your own question.

Reply With Quote
  #3  
Old May 20th, 2009, 09:12 PM
warp9 warp9 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 20 warp9 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 52 m 8 sec
Reputation Power: 0
Quote:
Originally Posted by Oler1s
You should eventually pick up on two ideas. The first is that you update the game only every so often. So if your game is clocked to 60 FPS, how many seconds elapse before an update? Or, you update the game as fast as possible. But you scale the updates to match the update speed. Let's say an object is moving at 1 meter/sec at 60 FPS. Your game runs at 100 FPS instead. How much distance should it being per frame in the 100FPS case?

I agree.

And I'll add the following: the scaling option an advantage. If you should run the program on a very slow machine (so you can't get your target frame rate), then you can still move the correct distance per second.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesGame Development > How to control FPS


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT