Too fast!

Silden
Unregistered
 
Post: #1
This isn't really a problem, it's more of a query. One of the current games I'm working on is a 2D openGL game which right now is currently working fine with one exception. The thing is absolutely flying. So what I'm wondering is what is/are some of the preferred methods of limiting the speed without really dropping frame rates? Before I've used Tickcounts to limit my previous games but that also dropped the frame rates and I'm thinking there has got to be a more elegant way of doing this. I'd rather do it the right way the first time then to have to go back and fix it later on. Thanks!
Quote this message in a reply
Hog
Member
Posts: 151
Joined: 2002.09
Post: #2
how about calculating object's actual positions for a measured time interval
Quote this message in a reply
Member
Posts: 114
Joined: 2002.08
Post: #3
Here is one for BASIC


At beginnging of loop:
ttime=timer

At end of loop:
stime=timer-ttime


In bewteen:
x=x+pixels_per_second*ttime

"Most nutritionists say that Twinkies are bad. But they're not, they're very very good."
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #4
NSTimer?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Use d=vt to move your objects, rather than using a constant d.

(That is, use time-based rather than frame-based animation)
Quote this message in a reply
Silden
Unregistered
 
Post: #6
Quote:Originally posted by OneSadCookie
Use d=vt to move your objects, rather than using a constant d.

(That is, use time-based rather than frame-based animation)


Right now the sprites are set with a given velocity, x and y which are ints. The screen is set as 800x600. It's also probably pushing upwards of about 80 fps. With this set up it's basically delta d=v. Do I just count the ticks per time through the movement functions and when it hit's a threshold (say 4 ticks) then run through the movement functions and check for input?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #7
Sync to VBL, so you only update as fast as the display device can refresh. There's no point in going any faster.

see http://developer.apple.com/technotes/tn/tn2014.html
Quote this message in a reply
Mars_999
Unregistered
 
Post: #8
Quote:Originally posted by OneSadCookie
Use d=vt to move your objects, rather than using a constant d.

(That is, use time-based rather than frame-based animation)


Ditto. Use timers
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  fast billboards reubert 2 2,801 Oct 7, 2004 04:41 AM
Last Post: OneSadCookie
  how fast should this be? <seb> 3 3,836 Feb 25, 2003 12:51 PM
Last Post: <seb>