Improve level generation speed

This commit is contained in:
jgk
2021-08-16 20:56:49 +02:00
parent 37db056f23
commit 650e58bdfa
11 changed files with 168 additions and 133 deletions
+11
View File
@@ -199,6 +199,17 @@ polyToTris (a:as) = go a as
go _ _ = []
polyToTris _ = []
polyToTris' :: [s] -> [s]
{-# INLINE polyToTris' #-}
polyToTris' [] = []
polyToTris' (a:as) = prependTwo a as
prependTwo :: a -> [a] -> [a]
prependTwo _ [] = []
prependTwo _ [_] = []
prependTwo sep (x:y:xs) = sep : x : y : prependTwo sep (y:xs)
-- | Return n equidistant points on a circle with a radius of 600.
nRays :: Int -> [Point2]
nRays n = take n $ iterate (rotateV (2*pi/fromIntegral n)) (V2 600 0)