16 lines
332 B
Haskell
16 lines
332 B
Haskell
module Dodge.Clock (
|
|
clockCycle,
|
|
) where
|
|
|
|
import Control.Lens
|
|
import qualified Data.Vector as V
|
|
import Dodge.Data.LWorld
|
|
|
|
clockCycle :: Int -> V.Vector a -> LWorld -> a
|
|
{-# INLINEABLE clockCycle #-}
|
|
clockCycle tPeriod xs w = xs V.! i
|
|
where
|
|
l = V.length xs
|
|
t = (w ^. lClock) `mod` (l * tPeriod)
|
|
i = t `div` tPeriod
|