How do I do real time based animation?

Get help using Construct 2

Post » Sat Mar 21, 2015 9:18 pm

Hi guys, I finally bought C2 (yay!) and I love it. I started with the flappy tutorial as a basis for my first small game, however now when I test the game on different browsers I realised that if a particular browser is low on fps the pipes are spawning much closer to each other making the game much harder (and sometimes impossible).

Normally when programming games you would separate the logic and the the rendering of the screen, so if the logic can't keep up the framerate would drop instead of slowing the whole game down. I guess there's probably some smart way to do this in C2 aswell but I just can't come to think of any way to accomplish this right now. I couldn't really find anything when googling and searching the forum either so I would be eternally gratefull if someone could point me in the right direction or enlighten me with some hints on how to solve this.
B
4
Posts: 12
Reputation: 263

Post » Sat Mar 21, 2015 10:33 pm

I assume you're talking about this tutorial, in which case you should read this other tutorial about delta time. The previously mentioned tutorial doesn't make use of delta time for object movement, resulting in framerate dependence.

As an example from the tutorial, they use this framerate dependent expression:

Code: Select all
Pipebottom.X - 5

Which, if you're assuming the game runs at 60 FPS, is equivalent to this framerate independent expression:

Code: Select all
Pipebottom.X - 300 * dt

Which would move the pipe at 300 pixels per second, just as the first expression would if running at 60 FPS. At a lower framerate, such as 30 FPS, the second expression would still move the pipe at 300 pixels per second, while the first would halve to 150 pixels per second.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,106

Post » Sat Mar 21, 2015 10:49 pm

Hey thanks so much man, that's exactly what I was looking for! I'm truly thankfull!
B
4
Posts: 12
Reputation: 263


Return to How do I....?

Who is online

Users browsing this forum: abman, Hex27, morti, supervanz, Yahoo [Bot] and 3 guests