Skip to content

Commit dfd6463

Browse files
authored
Set max frame rate to 35 FPS (#2558)
For a long time the max frame rate has been arbitrarily set to 30 FPS. (The reason we have a max frame rate set at all is so that the game doesn't just eat 100% of your CPU.) However, since the default speed is 16 ticks/s, doubling it results in 32 ticks/s, which at a frame rate of 30 FPS will run just under one frame per tick. i.e. if you speed up the game just a bit, there will necessarily start being dropped ticks that are not rendered as a frame. This seems unfortunate, so I propose upping the max frame rate slightly to better correspond to the power-of-two tick rates. Setting the FPS to 32 exactly will probably still result in occasional dropped ticks (typically the actual frame rate hovers slightly below the maximum), so I propose setting it to 35.
1 parent 57f933c commit dfd6463

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/game/Swarm/App.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,21 @@ startMetricsThread mPort store = do
152152
createChannel :: IO (BChan AppEvent)
153153
createChannel = newBChan 5
154154

155-
-- | Send Frame events as at a reasonable rate for 30 fps.
155+
-- | Send Frame events as at a reasonable rate for 35 fps.
156156
--
157157
-- The game is responsible for figuring out how many steps to take
158158
-- each frame to achieve the desired speed, regardless of the
159-
-- frame rate. Note that if the game cannot keep up with 30
159+
-- frame rate. Note that if the game cannot keep up with 35
160160
-- fps, it's not a problem: the channel will fill up and this
161161
-- thread will block. So the force of the threadDelay is just
162162
-- to set a *maximum* possible frame rate.
163+
--
164+
-- We use 35 FPS so that even at double the default ticks/second
165+
-- (i.e. 32 t/s) we can run at over 1 frame per tick.
163166
sendFrameEvents :: BChan AppEvent -> IO ()
164167
sendFrameEvents chan = void . forkIO . forever $ do
165168
writeBChan chan Frame
166-
threadDelay 33_333 -- cap maximum framerate at 30 FPS
169+
threadDelay (1_000_000 `div` 35) -- cap maximum framerate at 35 FPS
167170

168171
-- | Get newer upstream version and send event to channel.
169172
sendUpstreamVersion :: BChan AppEvent -> Maybe GitInfo -> IO ()

0 commit comments

Comments
 (0)