packages feed

aztecs-sdl-image 0.3.0 → 0.4.0

raw patch · 2 files changed

+18/−28 lines, 2 filesdep ~aztecsdep ~aztecs-sdl

Dependency ranges changed: aztecs, aztecs-sdl

Files

aztecs-sdl-image.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name:          aztecs-sdl-image-version:       0.3.0+version:       0.4.0 license:       BSD-3-Clause license-file:  LICENSE maintainer:    matt@hunzinger.me@@ -12,12 +12,12 @@                object (e.g. sword, monster, etc), in the game has a unique EntityId. Each                entity has various Components associated with it (material, weight, damage, etc).                Systems act on entities which have the required Components.-homepage:      https://github.com/matthunz/aztecs+homepage:      https://github.com/aztecs-hs/aztecs-sdl-image category:      Game Engine  source-repository head     type:     git-    location: https://github.com/matthunz/aztecs.git+    location: https://github.com/aztecs-hs/aztecs-sdl-image.git  library     exposed-modules:@@ -27,8 +27,8 @@     ghc-options:      -Wall     build-depends:         base >=4.6 && <5,-        aztecs >= 0.5,-        aztecs-sdl >= 0.1,+        aztecs >= 0.7 && <0.8,+        aztecs-sdl >= 0.4 && <0.5,         containers >=0.6,         deepseq >= 1,         mtl >=2,
src/Aztecs/SDL/Image.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE DeriveAnyClass #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE DeriveGeneric #-}+{-# LANGUAGE DerivingStrategies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TupleSections #-}@@ -43,6 +44,7 @@ import Aztecs.Time import Control.Arrow (Arrow (..), (>>>)) import Control.DeepSeq+import Control.Monad.IO.Class import Data.Maybe (mapMaybe) import Data.Word (Word32) import GHC.Generics (Generic)@@ -57,7 +59,7 @@ setup :: System () () setup = Asset.setup @Texture -load :: Schedule IO () ()+load :: (MonadIO m) => Schedule m () () load = Asset.loadAssets @Texture  draw :: System () ()@@ -71,11 +73,9 @@   loadAsset path _ = Texture <$> IMG.load path  -- | Image component.-data Image = Image-  { imageTexture :: !(Handle Texture),-    imageSize :: !(V2 Int)-  }-  deriving (Show, Generic, NFData)+newtype Image = Image {imageTexture :: Handle Texture}+  deriving (Generic)+  deriving newtype (Show, NFData)  instance Component Image @@ -88,26 +88,20 @@         mapMaybe (\(eId, img) -> (,img,eId) <$> lookupAsset (imageTexture img) assets) imgs   S.queue (mapM_ go) -< newAssets   where-    go (texture, _, eId) = do-      A.insert-        eId-        Surface-          { sdlSurface = textureSurface texture,-            surfaceBounds = Nothing-          }+    go (texture, _, eId) =+      A.insert eId Surface {sdlSurface = textureSurface texture, surfaceBounds = Nothing}  -- | Sprite component. data Sprite = Sprite   { spriteTexture :: !(Handle Texture),-    spriteBounds :: !(Maybe (Rectangle Int)),-    spriteSize :: !(V2 Int)+    spriteBounds :: !(Maybe (Rectangle Int))   }   deriving (Show)  instance Component Sprite  instance NFData Sprite where-  rnf (Sprite texture bounds size) = rnf texture `seq` (fmap (fmap rnf) bounds) `seq` rnf size+  rnf (Sprite texture bounds) = (fmap (fmap rnf) bounds) `seq` rnf texture  -- | Draw images to their target windows. drawSprites :: System () ()@@ -118,14 +112,10 @@         mapMaybe (\(eId, sprite) -> (,sprite,eId) <$> lookupAsset (spriteTexture sprite) assets) sprites   S.queue (mapM_ go) -< loadedAssets   where-    go (texture, sprite, eId) = do-      A.insert-        eId-        Surface-          { sdlSurface = textureSurface texture,-            surfaceBounds = spriteBounds sprite-          }+    go (texture, sprite, eId) =+      A.insert eId Surface {sdlSurface = textureSurface texture, surfaceBounds = spriteBounds sprite} +-- | Sprite animation component. data SpriteAnimation = SpriteAnimation   { spriteAnimationSteps :: ![Rectangle Int],     spriteAnimationIndex :: !Int,