Cleanup preload, add basic frame time checking

This commit is contained in:
2021-03-24 18:41:29 +01:00
parent f45ca2dd24
commit 3a52f3feaf
5 changed files with 40 additions and 43 deletions
+9 -8
View File
@@ -60,16 +60,17 @@ main = do
(worldPictures w)
blendFunc $= (SrcAlpha,OneMinusSrcAlpha)
renderFoldable (_renderData preData) (picToLTree Nothing $ fixedCoordPictures w)
endRenderTicks <- SDL.ticks
playSoundQueue (_soundData preData) (_soundQueue w)
newSoundData <- playAndUpdate (_sounds w) (_soundData preData)
endMixerTicks <- SDL.ticks
return $ (preData {_soundData = newSoundData})
& renderTime +~ (endRenderTicks - startTicks)
& mixerTime +~ (endMixerTicks - endRenderTicks)
& renderLighting +~ (lightTicks - startTicks)
& renderPicture +~ (endRenderTicks - lightTicks)
& pokeTime +~ timeSpentPoking
endTicks <- SDL.ticks
let lastFrameTicks = _frameTimer preData
renderFoldable (_renderData preData)
(picToLTree Nothing . setLayer 1 . setDepth (-1)
. translate 0 (-0.8) . scale 0.0005 0.0005
. text $ show (endTicks - lastFrameTicks))
return $ preData & soundData .~ newSoundData
& frameTimer .~ endTicks
)
(flip $ menuEvents $ flip handleEvent)
(\w -> Just $ update w)