Refactor modules
This commit is contained in:
+3
-16
@@ -4,21 +4,15 @@
|
||||
Basic helpers.
|
||||
Consider splitting. -}
|
||||
module Dodge.Base
|
||||
( module Dodge.Base
|
||||
, module Dodge.Base.Zone
|
||||
, module Dodge.Base.Window
|
||||
, module Dodge.Base.Collide
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Base.Zone
|
||||
import Dodge.Base.Window
|
||||
import Dodge.Base.Collide
|
||||
import Geometry
|
||||
--import Picture
|
||||
import qualified IntMapHelp as IM
|
||||
import FoldableHelp
|
||||
|
||||
import Data.Foldable
|
||||
import Control.Lens
|
||||
--import Control.Monad.State
|
||||
--import Data.List
|
||||
@@ -47,7 +41,7 @@ midPadL i x xs ys = take j (xs ++ repeat x) ++ ys
|
||||
{- | Implementation copied from
|
||||
- https://hackage.haskell.org/package/utility-ht-0.0.16/docs/src/Data.List.HT.Private.html#takeUntil
|
||||
-}
|
||||
takeUntil :: (a -> Bool) -> [a] -> [a]
|
||||
takeUntil :: Foldable t => (a -> Bool) -> t a -> [a]
|
||||
takeUntil p = foldr (\x xs -> x : if p x then [] else xs) []
|
||||
|
||||
you :: World -> Creature
|
||||
@@ -124,7 +118,7 @@ creaturesNearPointI n p w = IM.unions [f b $ f a $ _creaturesZone w | a<-[x-n..
|
||||
|
||||
cloudsNearPoint :: Point2 -> World -> [Cloud]
|
||||
--cloudsNearPoint p w = IM.unions [f b $ f a $ _cloudsZone w | a<-[x-1,x,x+1] , b<-[y-1,y,y+1]]
|
||||
cloudsNearPoint p w = f ((IM.lookup x $ _cloudsZone w) >>= IM.lookup y)
|
||||
cloudsNearPoint p w = f (IM.lookup x (_cloudsZone w) >>= IM.lookup y)
|
||||
where
|
||||
(x,y) = cloudZoneOfPoint p
|
||||
f Nothing = []
|
||||
@@ -495,13 +489,6 @@ isAnimate cr = case _crActionPlan cr of
|
||||
sigmoid :: Floating a => a -> a
|
||||
sigmoid x = x/sqrt(1+x^(2::Int))
|
||||
|
||||
{- | In order to force a list, apply with seq. -}
|
||||
forceSpine :: [a] -> ()
|
||||
forceSpine = foldr (const id) ()
|
||||
|
||||
forceList :: [a] -> [a]
|
||||
forceList l = seq (forceSpine l) l
|
||||
|
||||
normalizeAnglePi :: Float -> Float
|
||||
normalizeAnglePi angle
|
||||
| normalizeAngle angle > pi = normalizeAngle angle - 2*pi
|
||||
|
||||
Reference in New Issue
Block a user