Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Lower framerate equal lower speed???

Author
Message
F4SHAD0
13
Years of Service
User Offline
Joined: 28th Jan 2011
Location: Behind You
Posted: 22nd Mar 2011 03:37
Hello, and hope all is well. Now, on to my problem. When I set dbSyncRate (n) to 60, then for loop some objects in, my frames drop to about 20 - 25 fps. You would think that after programming quite a few test apps with Dark GDK, I would have figured this out by now. The problem? When my frames drop to that range, the game slows down. Now, from playing Jason P Sages "Iron Tanks", he has his frames capped at 25 I think, yet no slow down. The question? How would I speed up the game when the frames drop? Any advice would be helpful.

- James
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 22nd Mar 2011 08:14 Edited at: 22nd Mar 2011 08:31
First of all you should try to figure out why your frame rate drops to 20 because it shouldn't. Just because you "put some objects in", with a good graphic card it shouldn't be so slow.

If your whole game slows down, then I suppose you calculate the movement of your objects linked to frame rate? Use timer-based movement, then the speed of objects will be independent of the FPS value.
F4SHAD0
13
Years of Service
User Offline
Joined: 28th Jan 2011
Location: Behind You
Posted: 23rd Mar 2011 23:55
Sorry, for the no response. AT&T was doing some work outside so internet was down. Anyway, could you provide a sample of what you mean? I don't mean post code, just a simple walk through. I'm not sure how to go about timer-based movement.
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 24th Mar 2011 20:43 Edited at: 24th Mar 2011 20:45
It's simple: determine the speed of objects in "pixels per second", "meters per second", "turn angle per second" or whatever speed unit you need for the game. Then measure the time elapsed since the last screen refresh and calculate how much distance you need to move in that time. (distance = speed * time)

Here are two programs to illustrate the difference between loop-based and timer-based movement. They show a rotating cube. Hopefully the difference will be visible when you run them. With the Space key you can switch between FPS 10 and 60. First, the loop-based version. (Most of it is the testing code to switch between frame rates, the movement itself is a short code.)



Next, the timer-based. When you switch to a low framerate, it will be jumpy because the screen is not refreshed often enough to create a smooth movement for the eye, but the rotation will not slow down.

F4SHAD0
13
Years of Service
User Offline
Joined: 28th Jan 2011
Location: Behind You
Posted: 25th Mar 2011 23:19
Thanks a lot. I'll give it a try and report back.

P.S.: I was wasn't asking for code because it makes it look like I am begging and not wanting to put in the work. But, thanks anyway.
F4SHAD0
13
Years of Service
User Offline
Joined: 28th Jan 2011
Location: Behind You
Posted: 26th Mar 2011 00:09 Edited at: 26th Mar 2011 00:49
All right, it works. Here is the code.



One other thing, how do I control how fast the player moves. Like, I want to speed it ( the box ) up and slow it down when the key is released.
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 26th Mar 2011 14:58 Edited at: 26th Mar 2011 15:00
I know you didn't ask code, it was just easier to show the code than to explain in words, and I wanted to test what I'm saying too.

For speeding up and slowing down the box, you could introduce an acceleration value. When the forward key is pressed, add a little to the speed until it reaches a maximum. When it's not pressed, deduct the acceleration from the speed until it reaches zero. The acceleration can also be based on time.

Login to post a reply

Server time is: 2024-06-16 00:01:45
Your offset time is: 2024-06-16 00:01:45