|
-
Sep 26th, 2002, 07:15 AM
#1
Thread Starter
Addicted Member
FPS vs. Speed of movement
You know how on some computers a game can run at 100fps and on others the same game will run at like 60 or 50fps. Well I have a quesion. If I want to move a sprite 5 pixels to the right, that is a fast enough pace when running at 100fps, but it is not fast enough if running at 50fps. So is it a good idea to tie together the FPS you are getting with the speed of movment of your sprite? Say if I run at 100fps then speed = 5 if 80fps then speed = 6, if 60fps then speed = 7...etc
Would that work, how do you guys do it?
-
Sep 26th, 2002, 07:28 AM
#2
So Unbanned
Yea, FPS is inversely proportional to movement.
-
Sep 26th, 2002, 09:25 AM
#3
Addicted Member
Normally sprite movement has nothing to do with frame rate, it's time dependant. Your sprite would move at the same rate no matter what your frame rate is. The only problem you'll have is when your frame rate gets really really low. On a decent machine though it shouldn't be a problem.
-
Sep 26th, 2002, 10:15 AM
#4
Frenzied Member
Get b****ed at the last time I posted this code...
Code:
Dim tDelta As Single
Dim s As Long
Dim e As Long
...
While True 'Your game loop
s = GetTickCount()
'Do Stuff
DoEvents
e = GetTickCount()
tDelta = CSng(e - s) / 1000.0
Wend
tDelta contains the fraction of a second your frame took to loop once. Simply multiply the distance you want your sprite to move in one second by tDelta, and add it to the sprite's position. Using this method, FPS = 1.0 / tDelta.
Z.
-
Sep 26th, 2002, 10:16 AM
#5
Frenzied Member
Oh, and you have to do your movement EVERY frame.
Z.
-
Sep 26th, 2002, 12:20 PM
#6
Addicted Member
If you do your movement every time through the game loop and the sprite is a person walking, you'll potentially have the sprite moving without the legs moving since you'll only have a certain number of frames in the sprite animation. Though if you have enough frames of animation it may not be noticeable.
-
Sep 26th, 2002, 06:03 PM
#7
Thread Starter
Addicted Member
Ok, thanks I'll try that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|