diff options
author | Juan J. Martinez <jjm@usebox.net> | 2024-05-17 12:39:14 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2024-05-17 12:39:14 +0100 |
commit | 74298ef8ff9c3730d56b123e59b14ee0b8778772 (patch) | |
tree | 3789a8d6df93013bdbee3604b320e074169b2ca8 | |
parent | e44005c482d86aa30739ac97ad11e2c7c0fd0238 (diff) | |
download | space-plat-hs-74298ef8ff9c3730d56b123e59b14ee0b8778772.tar.gz space-plat-hs-74298ef8ff9c3730d56b123e59b14ee0b8778772.zip |
-rw-r--r-- | game.cabal | 53 | ||||
-rw-r--r-- | src/Game.hs | 22 | ||||
-rw-r--r-- | src/Game/BitmapFont.hs | 6 | ||||
-rw-r--r-- | src/Game/Controller.hs | 8 | ||||
-rw-r--r-- | src/Game/Entities.hs | 10 | ||||
-rw-r--r-- | src/Game/Entities/Blast.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Common.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Effect.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Entry.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Exit.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Pickup.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Player.hs | 4 | ||||
-rw-r--r-- | src/Game/Entities/Robot.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Runner.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Shooter.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Slime.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Tracker.hs | 2 | ||||
-rw-r--r-- | src/Game/Entities/Types.hs | 2 | ||||
-rw-r--r-- | src/Game/Hud.hs | 8 | ||||
-rw-r--r-- | src/Game/Map.hs | 6 | ||||
-rw-r--r-- | src/Game/Sprites.hs | 4 | ||||
-rw-r--r-- | src/Game/State.hs | 2 | ||||
-rw-r--r-- | src/Game/Toaster.hs | 4 | ||||
-rw-r--r-- | src/Game/Utils.hs | 2 |
24 files changed, 75 insertions, 78 deletions
@@ -1,17 +1,16 @@ cabal-version: 2.4 name: game version: 0.1.0.0 - -synopsis: A gamedev experiment (2D platform game). -homepage: https://git.usebox.net/space-plat-hs/about/ - license: MIT license-file: LICENSE -author: Juan J. Martinez maintainer: jjm@usebox.net - -extra-source-files: CHANGELOG.md, README.md, LICENSE - +author: Juan J. Martinez +homepage: https://git.usebox.net/space-plat-hs/about/ +synopsis: A gamedev experiment (2D platform game). +extra-source-files: + CHANGELOG.md + README.md + LICENSE library exposed-modules: @@ -39,31 +38,29 @@ library Game.Controller Game.Utils Game.Toaster - build-depends: - base - , text >= 1.1.0.0 && < 2.1 - , vector >= 0.10.9.0 && <= 0.14 - , containers - , sdl2 - , sdl2-image - , json - , random - ghc-options: -Wall -Werror -O2 -j + hs-source-dirs: src + default-language: GHC2021 default-extensions: - OverloadedStrings - OverloadedRecordDot - DuplicateRecordFields + OverloadedStrings OverloadedRecordDot DuplicateRecordFields NoFieldSelectors - hs-source-dirs: src - default-language: Haskell2010 -executable game - main-is: Main.hs + ghc-options: -Wall -Werror -O2 -j build-depends: - base - , game - ghc-options: -Wall -Werror -with-rtsopts=--nonmoving-gc -O2 + base, + text >=1.1.0.0 && <2.1, + vector >=0.10.9.0 && <=0.14, + containers, + sdl2, + sdl2-image, + json, + random +executable game + main-is: Main.hs hs-source-dirs: app default-language: GHC2021 + ghc-options: -Wall -Werror -with-rtsopts=--nonmoving-gc -O2 + build-depends: + base, + game diff --git a/src/Game.hs b/src/Game.hs index 3338a8c..343e23a 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -5,18 +5,18 @@ import Data.IORef import Data.Maybe (fromMaybe) import Data.Text (pack) import Foreign.C.Types (CInt) -import qualified Game.BitmapFont as BF -import qualified Game.Controller as C -import qualified Game.Entities as E -import qualified Game.Hud as H -import qualified Game.Map as M -import qualified Game.Sprites as S -import qualified Game.State as GS -import qualified Game.Toaster as T -import qualified Game.Utils as U +import Game.BitmapFont qualified as BF +import Game.Controller qualified as C +import Game.Entities qualified as E +import Game.Hud qualified as H +import Game.Map qualified as M +import Game.Sprites qualified as S +import Game.State qualified as GS +import Game.Toaster qualified as T +import Game.Utils qualified as U import SDL (($=)) -import qualified SDL -import qualified SDL.Image +import SDL qualified +import SDL.Image qualified import SDL.Vect (V2 (..)) name :: String diff --git a/src/Game/BitmapFont.hs b/src/Game/BitmapFont.hs index 66b9b5d..dd92a3a 100644 --- a/src/Game/BitmapFont.hs +++ b/src/Game/BitmapFont.hs @@ -2,12 +2,12 @@ module Game.BitmapFont (BitmapFont, load, renderText, renderTextSolid) where import Control.Monad import Data.Map (Map) -import qualified Data.Map as Map +import Data.Map qualified as Map import Data.Maybe (fromMaybe) import Foreign.C.Types (CInt) -import qualified Game.Utils as U +import Game.Utils qualified as U import SDL (($=)) -import qualified SDL +import SDL qualified import Text.JSON data FontDesc = FontDesc Int Int (Map Char (SDL.Rectangle CInt)) diff --git a/src/Game/Controller.hs b/src/Game/Controller.hs index 0914766..f2cd5cd 100644 --- a/src/Game/Controller.hs +++ b/src/Game/Controller.hs @@ -4,10 +4,10 @@ import Control.Monad import Data.Int (Int32) import Data.Maybe (fromMaybe, isNothing) import Foreign.C (peekCAString) -import qualified Game.Toaster as T -import qualified SDL -import qualified SDL.Input.GameController as SDL -import qualified SDL.Raw +import Game.Toaster qualified as T +import SDL qualified +import SDL.Input.GameController qualified as SDL +import SDL.Raw qualified import Prelude hiding (init) data Controls = Controls diff --git a/src/Game/Entities.hs b/src/Game/Entities.hs index 0f2f03e..b48e55d 100644 --- a/src/Game/Entities.hs +++ b/src/Game/Entities.hs @@ -15,7 +15,7 @@ import Data.Bits (Bits (..)) import Data.Foldable (find, traverse_) import Data.IORef import Data.List (sort) -import qualified Game.Controller as C +import Game.Controller qualified as C import Game.Entities.Blast import Game.Entities.Common import Game.Entities.Const @@ -30,10 +30,10 @@ import Game.Entities.Shooter import Game.Entities.Slime import Game.Entities.Tracker import Game.Entities.Types -import qualified Game.Map as M -import qualified Game.Sprites as S -import qualified Game.State as GS -import qualified SDL +import Game.Map qualified as M +import Game.Sprites qualified as S +import Game.State qualified as GS +import SDL qualified mkEntities :: S.SpriteSheet -> M.Map -> IORef C.Controls -> IO Entities mkEntities sprites m controls = do diff --git a/src/Game/Entities/Blast.hs b/src/Game/Entities/Blast.hs index 6e9fec2..6f3c890 100644 --- a/src/Game/Entities/Blast.hs +++ b/src/Game/Entities/Blast.hs @@ -3,7 +3,7 @@ module Game.Entities.Blast (mkBlast) where import Data.Bits (Bits (..)) import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkBlast :: S.SpriteSheet -> Int -> Int -> Dir -> Collision -> IsBlocked -> IO Entity mkBlast sprites x y dir playerCollision isBlocked = do diff --git a/src/Game/Entities/Common.hs b/src/Game/Entities/Common.hs index 8fa7fe3..0ccfdf5 100644 --- a/src/Game/Entities/Common.hs +++ b/src/Game/Entities/Common.hs @@ -13,7 +13,7 @@ where import Data.IORef import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S -- | Return the opposite direction. turn :: Dir -> Dir diff --git a/src/Game/Entities/Effect.hs b/src/Game/Entities/Effect.hs index 6f056d8..682ce0f 100644 --- a/src/Game/Entities/Effect.hs +++ b/src/Game/Entities/Effect.hs @@ -3,7 +3,7 @@ module Game.Entities.Effect (mkEffect) where import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkEffect :: S.SpriteSheet -> Int -> Int -> String -> IO Entity mkEffect sprites x y name = do diff --git a/src/Game/Entities/Entry.hs b/src/Game/Entities/Entry.hs index 18e29df..d1b5c10 100644 --- a/src/Game/Entities/Entry.hs +++ b/src/Game/Entities/Entry.hs @@ -3,7 +3,7 @@ module Game.Entities.Entry (mkEntry) where import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S openingDoorSet :: Int openingDoorSet = 2 diff --git a/src/Game/Entities/Exit.hs b/src/Game/Entities/Exit.hs index f5e01a8..9c8bf82 100644 --- a/src/Game/Entities/Exit.hs +++ b/src/Game/Entities/Exit.hs @@ -3,7 +3,7 @@ module Game.Entities.Exit (mkExit) where import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S closingDoorSet :: Int closingDoorSet = 1 diff --git a/src/Game/Entities/Pickup.hs b/src/Game/Entities/Pickup.hs index 7d6022c..95b8e25 100644 --- a/src/Game/Entities/Pickup.hs +++ b/src/Game/Entities/Pickup.hs @@ -3,7 +3,7 @@ module Game.Entities.Pickup (mkBattery) where import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkBattery :: S.SpriteSheet -> Int -> Int -> Collision -> IO Entity mkBattery sprites x y playerCollision = do diff --git a/src/Game/Entities/Player.hs b/src/Game/Entities/Player.hs index 72de1bb..097d159 100644 --- a/src/Game/Entities/Player.hs +++ b/src/Game/Entities/Player.hs @@ -1,11 +1,11 @@ module Game.Entities.Player (mkPlayer, dyingSet) where import Data.IORef -import qualified Game.Controller as C +import Game.Controller qualified as C import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S dyingSet :: Int dyingSet = 2 diff --git a/src/Game/Entities/Robot.hs b/src/Game/Entities/Robot.hs index 5cc9d70..94e721d 100644 --- a/src/Game/Entities/Robot.hs +++ b/src/Game/Entities/Robot.hs @@ -4,7 +4,7 @@ import Data.Bits (Bits (..)) import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkRobot :: S.SpriteSheet -> Int -> Int -> Dir -> Collision -> IsBlocked -> IO Entity mkRobot sprites x y d playerCollision isBlocked = do diff --git a/src/Game/Entities/Runner.hs b/src/Game/Entities/Runner.hs index 288f2b4..76f0db2 100644 --- a/src/Game/Entities/Runner.hs +++ b/src/Game/Entities/Runner.hs @@ -4,7 +4,7 @@ import Data.Bits (Bits (..)) import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S import System.Random (randomRIO) mkRunner :: S.SpriteSheet -> Int -> Int -> Dir -> Collision -> IsBlocked -> IsBlocked -> IO Entity diff --git a/src/Game/Entities/Shooter.hs b/src/Game/Entities/Shooter.hs index 6e9675f..3a085e4 100644 --- a/src/Game/Entities/Shooter.hs +++ b/src/Game/Entities/Shooter.hs @@ -4,7 +4,7 @@ import Data.Bits (Bits (..)) import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S blasterCoolDown :: Int blasterCoolDown = 128 diff --git a/src/Game/Entities/Slime.hs b/src/Game/Entities/Slime.hs index 0cc805b..fdae057 100644 --- a/src/Game/Entities/Slime.hs +++ b/src/Game/Entities/Slime.hs @@ -4,7 +4,7 @@ import Data.Bits (Bits (..)) import Game.Entities.Common import Game.Entities.Const import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkSlime :: S.SpriteSheet -> Int -> Int -> Dir -> Collision -> IsBlocked -> IO Entity mkSlime sprites x y d playerCollision isBlocked = do diff --git a/src/Game/Entities/Tracker.hs b/src/Game/Entities/Tracker.hs index 9baac80..f60fc20 100644 --- a/src/Game/Entities/Tracker.hs +++ b/src/Game/Entities/Tracker.hs @@ -3,7 +3,7 @@ module Game.Entities.Tracker (mkTracker) where import Game.Entities.Const import Game.Entities.Runner import Game.Entities.Types -import qualified Game.Sprites as S +import Game.Sprites qualified as S mkTracker :: S.SpriteSheet -> Int -> Int -> Dir -> Collision -> Collision -> IsBlocked -> IsBlocked -> IO Entity mkTracker sprites x y d playerCollision facingPlayerLower isBlocked isBlockedDeadly = do diff --git a/src/Game/Entities/Types.hs b/src/Game/Entities/Types.hs index 765800f..8d78f22 100644 --- a/src/Game/Entities/Types.hs +++ b/src/Game/Entities/Types.hs @@ -11,7 +11,7 @@ module Game.Entities.Types where import Data.IORef -import qualified Game.Sprites as S +import Game.Sprites qualified as S data Dir = DirRight | DirLeft deriving (Eq, Show, Ord) diff --git a/src/Game/Hud.hs b/src/Game/Hud.hs index c4d5234..a93166c 100644 --- a/src/Game/Hud.hs +++ b/src/Game/Hud.hs @@ -1,9 +1,9 @@ module Game.Hud (Hud, mkHud, render, height) where -import qualified Game.BitmapFont as BM -import qualified Game.Sprites as S -import qualified Game.State as GS -import qualified SDL +import Game.BitmapFont qualified as BM +import Game.Sprites qualified as S +import Game.State qualified as GS +import SDL qualified height :: Int height = 16 diff --git a/src/Game/Map.hs b/src/Game/Map.hs index 425d0db..dbb0e6c 100644 --- a/src/Game/Map.hs +++ b/src/Game/Map.hs @@ -21,11 +21,11 @@ import Control.Applicative ((<|>)) import Control.Monad import Data.Maybe (fromMaybe) import Data.Vector (Vector) -import qualified Data.Vector as Vector +import Data.Vector qualified as Vector import Game.Entities.Types (Dir (..)) -import qualified Game.Utils as U +import Game.Utils qualified as U import SDL (($=)) -import qualified SDL +import SDL qualified import Text.JSON import Text.JSON.Types diff --git a/src/Game/Sprites.hs b/src/Game/Sprites.hs index 3e8c195..a49dbcd 100644 --- a/src/Game/Sprites.hs +++ b/src/Game/Sprites.hs @@ -11,8 +11,8 @@ where import Control.Monad import Data.List (find) import Foreign.C.Types (CInt) -import qualified Game.Utils as U -import qualified SDL +import Game.Utils qualified as U +import SDL qualified import SDL.Vect (V2 (..)) import Text.JSON diff --git a/src/Game/State.hs b/src/Game/State.hs index 5c9de0b..dd50f88 100644 --- a/src/Game/State.hs +++ b/src/Game/State.hs @@ -1,7 +1,7 @@ module Game.State (State (..), initialState, levelState, maxLives, PlayState (..)) where import Game.Entities.Const (hitDelay) -import qualified Game.Map as M +import Game.Map qualified as M maxLives :: Int maxLives = 4 diff --git a/src/Game/Toaster.hs b/src/Game/Toaster.hs index 190365e..671473b 100644 --- a/src/Game/Toaster.hs +++ b/src/Game/Toaster.hs @@ -8,8 +8,8 @@ module Game.Toaster where import Data.Foldable (traverse_) -import qualified Game.BitmapFont as BM -import qualified SDL +import Game.BitmapFont qualified as BM +import SDL qualified toastDelay :: Int toastDelay = 128 diff --git a/src/Game/Utils.hs b/src/Game/Utils.hs index d4dae94..35bb7f6 100644 --- a/src/Game/Utils.hs +++ b/src/Game/Utils.hs @@ -1,7 +1,7 @@ module Game.Utils (rect) where import Foreign.C.Types (CInt) -import qualified SDL +import SDL qualified import SDL.Vect (V2 (..)) rect :: Int -> Int -> Int -> Int -> SDL.Rectangle CInt |