[REQUEST] Developer to set FPS

Discussion and feedback on Construct 2

Post » Wed Nov 13, 2013 4:20 am

@AnD4D
That's right. You shouldn't be using dt. I understand the the desire too. but it's a bad idea. Box2D isn't built to work with dt. Box2D has a straight foward information that the results of Physics from Box2D are dependent on the binary being run on. So this means that results will be different from different CPU render levels.

Box2D suggestion is to just use different levels of settings for the devices. This is annoying. Instead there is a way better alternative. There is a high resolution fixed time step for Box2D. but it needs to be programmed in manually to the use of Box2D. The problem is that C2 fixed time step is rudemntary and not advanced enough to handle different platforms. You will need to modify physics timestep option. So every tick you will need t modify how many steps the Physics will use. This will smooth your physics.

Also I want to point out that I'm not convinced that the 30fps implementation in C2 right now is the right implementation. From what was written it sounds like option doesn't limit just FPS rendering to 30FPS, but also your entire game logic. How hard is it to just say. Draw On Time X and to set that time X. I get the feeling this is an entire game slow down :( BUT I could be wrong and we might just need more practice.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Wed Nov 13, 2013 4:53 am

@jayderyu

In my game I have a variable that has dt taken away from it every tick. This is the timer. I have a physics object that is constantly pulled in directions using force.

Without dt, at 60fps, it's fine. On my mobile device, on occasion it's so slow the timer manages to run out before the physics object manages to drop. If dt is already on physics objects, why does this happen?

If I add dt to the force, it seems fine on my mobile device. I'm so confused. I'll switch it back to without dt, but I'm not sure what's going on.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Wed Nov 13, 2013 5:56 am

@AnD4D
because dt is still based on a millisecond clock. C2 uses dt based on a 60fps millisecond clock. So when you use dt your trying to create a universal math and multiplied value. The reason and it's just suspect reason that the 30fps dt isn't the same due to the idea that yoru also only processing logic at 30fps rather than continuing to handle logic at 60fps.

Not that I would associate logic to FPS at all. I'm just using that as an anology.

So on
PC, box.ImpulseAngle(0, 100 * dt)
iPAd, box.ImpulseAngle(0, 100 * dt)
In theory tries to unify the the force based on the clock. So results should be similar.

How physics works is that Box2D uses a time step.
Each time step consists of 2 primary values.*
* Step
Step is the amount of px the objects moves per itteration. Large steps allow for farther movement. but this reduces accuracy for collision detection. This can lead bullets to shoot through objects.

*Itteration
The number of times the physics shuold take 1 step(above). The more itterations a Physics.Render will call step.

Now when a programmer makes the basic timestep. it tries to take into account the difference of time from last frame render and how many Itterations shuold be called. However this usually works best for FASTER computers and often the basic time step doesn't do very well on slower than the primary development computer.

This is the problem that's happening hear. Your slower computer can't keep up with out something to fix the speed value.

Now how does dt come into this.
Well keep in mind that the dt is a reference time between. 0.0 to 1.0. On a faster computer the dt is much smaller due to the fact that it does everything faster. Where as a slower computer dt is a larger number to compensate for the difference in time.

So when you set your mobile game to run at 29fps vsync it falls out of sync. And the reason I think this is happening is because yoru logic is now running at 29fps(speculation based on what I'm hearing. In theory with all the exrta time your logic should be able to more than keep up... unless your game logic is throttled.

So this is why I think the current C2 use of 30fps isn't to give developers more logic time for physics and game processing, but instead to slow down the game to run on older devices. So instead of giving you access to all the yummy CPU time. C2 drops everything.

That's all speculation of course. but it's one reason why your game is having troubles with the lower 30fps.. you don't have more CPU time you have less.
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Wed Nov 13, 2013 12:09 pm

@Colludium's results are pretty much what I saw: it did not work reliably, and it was still choppy even when half framerate mode was in effect and it was measuring 30 FPS. I'm not sure how it could be improved - the current algorithm is "if last frame was not skipped, and the last frame was less than 29ms ago, skip this frame". That ought to work with vsync-aligned ticks, but I guess browsers (and non-browser platforms like CocoonJS) treat their tick rates differently or give up vsync-aligning ticks in some cases. Perhaps this might be possible to do well in a native engine, but I think since there seems to be varied tick rate logic in each browser I doubt it is possible to make a high-quality framerate limiter that works across all browsers.

One solution might be to just alternate frames blindly (just skip every other frame regardless of timing). However on a 60 Hz monitor as soon as you drop to 29 FPS you might end up halving the framerate all the way down to 15 FPS again. I'll do some tests and see what really happens with that.
Scirra Founder
B
387
S
229
G
87
Posts: 24,245
Reputation: 192,160

Post » Wed Nov 13, 2013 2:18 pm

@ashley

Is it possible to force DT to be greater than/equal to 29ms instead of skipping? When you say skipping it sounds like it either still does the same calculations but skips rendering, or it ignores the processing for that tick.

Maybe make a "End of Tick" check, where if by the time it's done processing that tick, if 29ms has passed it goes through, but if not then it waits. This way you'll have some potential idling on the processing side, but it should never stutter on it's own if it can run at any framerate above 30fps smoothly as you're not halving a rate but just waiting until the rate is a certain amount. Well theoretically, but as far as I know you might be doing that already. :P

Other than that I do not know. IMO if you can't get it to work smoothly in a week you can always come back to it at a later time, as there are more important features to work on.Thndr2013-11-13 14:19:26
B
21
S
8
G
6
Posts: 346
Reputation: 4,891

Post » Thu Nov 14, 2013 9:40 pm

Ashley, thank you for continuing to look into this. I really think that this can be a tremendously important new feature, especially for action games.

Incidentally, how do other developers do it? What logic do they apply to only draw 30 times a second while processing logic at normal speed?ChrisAlgoo2013-11-14 21:51:38
B
17
S
4
G
4
Posts: 143
Reputation: 4,004

Post » Fri Nov 15, 2013 1:49 am

Since C2 uses a high resolution timer could C2 base it's draw.call on that. My math will be off of course as it's only a sample.

But wouldnt it be best to just use a system of

[code]
var draw_next;
var draw_skip =33.2;

while(gamerun){
process_logic();
if( draw_next < timer){
    draw();
    draw_next = timer + draw_skip;
}
}
[/code]

Of course there is fine tuning required. This is just a simple design. But this let's the game process logic at full speed. And once the time passes the draw process starts. This also let's the developer set the draw_skip value to whatever fps level they want.

Of course I have no idea what is currently implemented :|
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Fri Nov 15, 2013 3:13 am

Here is an interesting post.
http://www.koonsolo.com/news/dewitters-gameloop/

It works in reverse. instead of limiting FPS down. The idea is to instead always run the game logic at 25FPS and visual updates are rendered as fast as possible. however the interesting part is that if the game rendered less than 25FPS the game logic is still at 25FPS. This is pretty much more ideal in design.

A game logic flow always needs to be at a solid rate. This model could certainly achieve the desires of everyone on the list here.

Visual the game udpates as fast as possible, but logic is always set. This means even if the game hits heavy render areas where the game can slow down to a crawl logic still flows the same AND this means the game play remains smooth no matter what is happening.

This sounds like an ideal goal.

The Gameloop in question is the last one in the list. I think Ashley should check it out. Because let's be honest it's not that we want less FPS, we just want to maintain smooth game play and to do that we would reduce how often to render, but the reverse can also be true AND it could work well cross platform :)
B
90
S
18
G
9
Posts: 2,455
Reputation: 15,013

Post » Fri Nov 15, 2013 7:58 am

might fill in a question here:

What is a low power device these days ?

I recently got myself a new smartphone, I'm not too hot on the newest and latest and go for price/quality.

2 years ago I got myself the galaxy gio, a little less then 1ghz, 512mb ... not even 100$

2 months ago I got: LG5 something

dualcore 1,2 ghz, 512mb ...... not even 100$

Low quality cheap phones ....

Not to be a nag, but to have phones like these perform badly for which you reqquire 30 fps, I suggest you take a look at your programming.lennaert2013-11-15 08:01:07
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,552

Post » Fri Nov 15, 2013 10:51 am

I still remember the days when they added tables to HTML and half the people argued very heatedly, "browsers are hypertext viewers, it's not supposed to look like desktop publishing!"

Now we are working to get them controlling frame rate to the exact microsecond. I find this so funny.
B
226
S
60
G
33
Posts: 902
Reputation: 39,955

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 0 guests