## 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!
Member
Posts: 151
Joined: 2002.09
Post: #2
how about calculating object's actual positions for a measured time interval
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."
Moderator
Posts: 916
Joined: 2002.10
Post: #4
NSTimer?
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)
Silden
Unregistered

Post: #6
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?
Sage
Posts: 1,234
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
Mars_999
Unregistered

Post: #8