apecs-gloss 0.1.1 → 0.2.0
raw patch · 2 files changed
+8/−10 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Apecs.Gloss: Camera :: V2 Double -> Double -> Camera
+ Apecs.Gloss: Camera :: V2 Float -> Float -> Camera
- Apecs.Gloss: [camOffset] :: Camera -> V2 Double
+ Apecs.Gloss: [camOffset] :: Camera -> V2 Float
- Apecs.Gloss: [camScale] :: Camera -> Double
+ Apecs.Gloss: [camScale] :: Camera -> Float
- Apecs.Gloss: play :: Has w IO Camera => Display -> Color -> Int -> System w Picture -> (Event -> System w ()) -> (Double -> System w ()) -> System w ()
+ Apecs.Gloss: play :: Has w IO Camera => Display -> Color -> Int -> System w Picture -> (Event -> System w ()) -> (Float -> System w ()) -> System w ()
- Apecs.Gloss: windowToWorld :: Camera -> (Float, Float) -> V2 Double
+ Apecs.Gloss: windowToWorld :: Camera -> (Float, Float) -> V2 Float
Files
- apecs-gloss.cabal +1/−1
- src/Apecs/Gloss.hs +7/−9
apecs-gloss.cabal view
@@ -1,5 +1,5 @@ name: apecs-gloss-version: 0.1.1+version: 0.2.0 synopsis: Simple gloss renderer for apecs homepage: https://github.com/jonascarpay/apecs-physics#readme license: BSD3
src/Apecs/Gloss.hs view
@@ -14,8 +14,8 @@ import Apecs data Camera = Camera- { camOffset :: V2 Double- , camScale :: Double+ { camOffset :: V2 Float+ , camScale :: Float } deriving (Eq, Show, Read) instance Semigroup Camera where@@ -27,12 +27,10 @@ -- | Apply a camera transformation to a picture cameraTransform :: Camera -> Picture -> Picture cameraTransform (Camera (V2 cx cy) cs) =- Scale (f cs) (f cs) . Translate (f . negate $ cx) (f . negate $ cy)- where f = realToFrac+ Scale cs cs . Translate (-cx) (-cy) -windowToWorld :: Camera -> (Float,Float) -> V2 Double-windowToWorld (Camera cx cs) (x,y) = v ^/ cs - cx- where v = V2 (realToFrac x) (realToFrac y)+windowToWorld :: Camera -> (Float,Float) -> V2 Float+windowToWorld (Camera cx cs) (x,y) = V2 x y ^/ cs - cx instance Component Camera where type Storage Camera = Global Camera@@ -44,14 +42,14 @@ -> Int -- ^ Desired FPS -> System w Picture -- ^ Drawing function -> (Event -> System w ()) -- ^ Event handling function- -> (Double -> System w ()) -- ^ Stepping function, with a time delta argument.+ -> (Float -> System w ()) -- ^ Stepping function, with a time delta argument. -> System w () play disp col fps draw handle step = do w <- ask liftIO$ playIO disp col fps w draw' handle' step' where handle' event = runSystem $ handle event >> ask- step' dT = runSystem $ step (realToFrac dT) >> ask+ step' dT = runSystem $ step dT >> ask draw' = runSystem $ do cam <- get global cameraTransform cam <$> draw