ketys Posted September 24, 2015 Share Posted September 24, 2015 Hello, I've got a problem with my game. On very old devices it's playable with low fps. The player with this device is in advantage, because the game figure's moves are much slower and he can react very quickly. Even if the game is in the hardest mode, this "low fps player" can play the game very easy... So, how can I make the game unplayable on this low HW devices? I think, the main problem is that I've got a game logic/figure moves in game loop...so if the player has 4fps, then he has got only 4 chances to figuremoves instead of 60 (60fps). function gameLoop() { requestAnimationFrame(gameLoop); play(); renderer.render(stage);}function play() { if(startGame) { if(startGame && !started) { game.startGame(Date.now()); started = true; } if(end) { modals(); renderer.plugins.interaction.destroy(); dragon.rotate = dragon.prevRotate; } else { time.text = Math.floor(game.getElapsedTime() / 1000) + 's'; dragon.prevRotate = dragon.rotate; dragon.rotate += game.evalWindStrength(); dragon.rotation += dragon.rotate; dragon.position.x += (dragon.rotation * MOVEMENT_FACTOR); arrow.rotation += dragon.rotate; Math.abs(arrow.rotation) > Math.PI / 4 ? arrow.tint = 0xB31634 : arrow.tint = 0x22205B; // end game if(dragon.position.x < 600 || dragon.position.x > 1320) { end = true; started = false; } } } } Quote Link to comment Share on other sites More sharing options...
CtlAltDel Posted September 24, 2015 Share Posted September 24, 2015 You have to make sure you evaluate how much time has passed between each run of play(). And scale you movement accordingly. Say you rotate 1000 degrees per second. which is insanely fast, but makes explanation easier At 60 fps that means you should rotate +-16 degrees per play() callat 6 fps that means you should rotate +-160 degrees per play() call. But in your current implementation you rotate by a fixed amount. To counter that you have to scale your rotation by the time passed.For instance: addRotation = 1000 * ( millisecondsElapsed / 1000 );dragon.rotate += addRotation; Now if you run at slower FPS you will get stuttery graphics, but your rotation will be scaled by the time elapsed and those with slower framrates will rotate the proper amount regardless of fps. Lauromine 1 Quote Link to comment Share on other sites More sharing options...
ketys Posted September 25, 2015 Author Share Posted September 25, 2015 Thank you! :-) It works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.