PDA

View Full Version : Too fast!


Silden
2003.04.16, 05:00 PM
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!

Hog
2003.04.16, 05:08 PM
how about calculating object's actual positions for a measured time interval

Dr. Light
2003.04.16, 05:15 PM
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

skyhawk
2003.04.16, 05:21 PM
NSTimer?

OneSadCookie
2003.04.16, 05:40 PM
Use d=vt to move your objects, rather than using a constant d.

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

Silden
2003.04.16, 06:01 PM
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?

arekkusu
2003.04.16, 06:28 PM
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

Mars_999
2003.04.16, 06:40 PM
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