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.
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:
Pipebottom.X - 5[/code:1x7btbyk]
Which, if you're assuming the game runs at 60 FPS, is equivalent to this framerate [i]independent[/i] expression:
[code:1x7btbyk]Pipebottom.X - 300 * dt[/code:1x7btbyk]
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.
Develop games in your browser. Powerful, performant & highly capable.
Hey thanks so much man, that's exactly what I was looking for! I'm truly thankfull!