From 333d6558f813fa17d41d870bb814db4110dc7d00 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Sun, 10 Dec 2017 16:44:33 +0100 Subject: [PATCH 001/201] Simplifies travis file. Closes #58. --- .travis.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cdda45..c5e1d0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,21 @@ # The following enables several GHC versions to be tested; often it's enough to # test only against the last release in a major GHC version. Feel free to omit # lines listings versions you don't need/want testing for. -language: c -env: - - GHCVER=7.6.3 - - GHCVER=7.8.4 - - GHCVER=7.10.3 - - GHCVER=8.0.1 +language: haskell + +ghc: + - "7.6.3" + - "7.8.4" + - "7.10.3" + - "8.0.1" -# Note: the distinction between `before_install` and `install` is not important. before_install: - - unset CC -install: - - travis_retry sudo add-apt-repository -y ppa:hvr/ghc - travis_retry sudo apt-get update - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev - - travis_retry sudo apt-get install cabal-install-1.24 ghc-$GHCVER-prof ghc-$GHCVER-dyn alex-3.1.4 happy-1.19.5 - - export PATH=$HOME/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/1.24/bin:/opt/alex/3.1.4/bin:/opt/happy/1.19.5/bin:$PATH - - travis_retry cabal update script: - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect -notifications: - email: true - branches: only: - master @@ -37,4 +28,4 @@ deploy: secure: WQp6LHDPxGPlaFsFK1CGZaW5XSFX4+f3hLkglYFKTUzNNfmq0QXmqKJROLWrvwvTmipxguM0qZdsJTYIKJdIeECyD7dR2sZHMVpoaXgle9QkYyvoAs1o9wMbdjc/vYK4QpG9we9TPwHNalXJIkwKtoWA7IDxKQ56ln2sQLx6Qz2K/tDnq8bHNhe4U/7YRGc9K2TdiFkcimPY6BqPG/mRR8AI+q3P3YLg4x4GdDKXKtxwRdWuRQaidpog6H4xbdVAjEIlbCJ/Re1Ofjq1J5ESYN5NM84+b8TiMoVs7qeiqWNuid8YCGKUpuJ4JXPai63+EHP9vr0+DFxFZPEMm94f/Lo6B/2BtUB5KoC1baVItMVte9pqcjr1slf46VoeCtXmfCa3pKBQE4TZQl25pSGISHfYaiRuCZ/zo1Rd6PPOgbdaR9agHOVMugGkO55p8qWwhL7kle/Xu8oEyOiRTc/M1PAKXe5Fa1+Vz46FNtMqTlZo/Sa5ySC3QpBfhexXqbD6fO3032VRX9oNPFXuIwwjXQ0D2lGENHxxVahcqIPC4AZVDmL+9ME7k0JVDSk7zW5gQgGdEWvtCBTLahBBwbgFHoRZxlymGnMJWovcgP9cOyrjlbd/LGjd0Hp9LEaCPmMHE+yM0cgVpVUrFtTNt4O3nl14KLYCKZ+0mwkryqEF/LI= on: branch: master - condition: "$GHCVER = 8.0.1" + condition: "${TRAVIS_HASKELL_VERSION}=8.0.1 From e84590cab6ef97ba773ea2b2ac963ff3ed54334a Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Sun, 10 Dec 2017 16:50:11 +0100 Subject: [PATCH 002/201] Removes typo and ajusts layout. Refs #58. --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5e1d0c..42c80f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,17 @@ language: haskell ghc: - - "7.6.3" - - "7.8.4" - - "7.10.3" - - "8.0.1" + - "7.6.3" + - "7.8.4" + - "7.10.3" + - "8.0.1" before_install: - - travis_retry sudo apt-get update - - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev + - travis_retry sudo apt-get update + - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev script: - - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect + - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect branches: only: @@ -28,4 +28,4 @@ deploy: secure: WQp6LHDPxGPlaFsFK1CGZaW5XSFX4+f3hLkglYFKTUzNNfmq0QXmqKJROLWrvwvTmipxguM0qZdsJTYIKJdIeECyD7dR2sZHMVpoaXgle9QkYyvoAs1o9wMbdjc/vYK4QpG9we9TPwHNalXJIkwKtoWA7IDxKQ56ln2sQLx6Qz2K/tDnq8bHNhe4U/7YRGc9K2TdiFkcimPY6BqPG/mRR8AI+q3P3YLg4x4GdDKXKtxwRdWuRQaidpog6H4xbdVAjEIlbCJ/Re1Ofjq1J5ESYN5NM84+b8TiMoVs7qeiqWNuid8YCGKUpuJ4JXPai63+EHP9vr0+DFxFZPEMm94f/Lo6B/2BtUB5KoC1baVItMVte9pqcjr1slf46VoeCtXmfCa3pKBQE4TZQl25pSGISHfYaiRuCZ/zo1Rd6PPOgbdaR9agHOVMugGkO55p8qWwhL7kle/Xu8oEyOiRTc/M1PAKXe5Fa1+Vz46FNtMqTlZo/Sa5ySC3QpBfhexXqbD6fO3032VRX9oNPFXuIwwjXQ0D2lGENHxxVahcqIPC4AZVDmL+9ME7k0JVDSk7zW5gQgGdEWvtCBTLahBBwbgFHoRZxlymGnMJWovcgP9cOyrjlbd/LGjd0Hp9LEaCPmMHE+yM0cgVpVUrFtTNt4O3nl14KLYCKZ+0mwkryqEF/LI= on: branch: master - condition: "${TRAVIS_HASKELL_VERSION}=8.0.1 + condition: ${TRAVIS_HASKELL_VERSION}=8.0.1 From 89111c563fff2aefc78d97929d325c440cfbe654 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Sun, 10 Dec 2017 17:07:13 +0100 Subject: [PATCH 003/201] Adjusts the default travis install command. It needs to include the flags -f-wiimote and -f-kinect to disable wiimote and kinect. Refs #58. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 42c80f9..763460a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,9 @@ before_install: - travis_retry sudo apt-get update - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev +install: + - cabal install -f-wiimote -f-kinect --only-dependencies --enable-tests + script: - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect From 9485422ec2f265e675db53dddd211f785ee6f15b Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Tue, 12 Dec 2017 08:43:17 +0100 Subject: [PATCH 004/201] Adds a missint travis_retry. Refs #58 and #59. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 763460a..ece4da7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ before_install: - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev install: - - cabal install -f-wiimote -f-kinect --only-dependencies --enable-tests + - travis_retry cabal install -f-wiimote -f-kinect --only-dependencies --enable-tests script: - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect From 962e89b0763b29188859461e65fa092b6716a047 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Tue, 12 Dec 2017 08:45:54 +0100 Subject: [PATCH 005/201] Adjusts 'script' to improve consistency. The adjustment is logically closer to the default script. Refs #58 and #59. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ece4da7..1c0fbfb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ install: - travis_retry cabal install -f-wiimote -f-kinect --only-dependencies --enable-tests script: - - travis_retry cabal install --run-tests -v -j1 -f-wiimote -f-kinect + - travis_retry cabal configure -f-wiimote -f-kinect --enable-tests && cabal build && cabal test branches: only: From 762d8095c103ab0e6134d5ac90a633734666b28f Mon Sep 17 00:00:00 2001 From: Maxim Bielushkin Date: Mon, 22 Oct 2018 15:40:41 +0300 Subject: [PATCH 006/201] Update of travis file (add newer ghc versions) --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2cdda45..189d600 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,9 @@ env: - GHCVER=7.6.3 - GHCVER=7.8.4 - GHCVER=7.10.3 - - GHCVER=8.0.1 + - GHCVER=8.2.2 + - GHCVER=8.4.4 + - GHCVER=8.6.1 # Note: the distinction between `before_install` and `install` is not important. before_install: @@ -37,4 +39,4 @@ deploy: secure: WQp6LHDPxGPlaFsFK1CGZaW5XSFX4+f3hLkglYFKTUzNNfmq0QXmqKJROLWrvwvTmipxguM0qZdsJTYIKJdIeECyD7dR2sZHMVpoaXgle9QkYyvoAs1o9wMbdjc/vYK4QpG9we9TPwHNalXJIkwKtoWA7IDxKQ56ln2sQLx6Qz2K/tDnq8bHNhe4U/7YRGc9K2TdiFkcimPY6BqPG/mRR8AI+q3P3YLg4x4GdDKXKtxwRdWuRQaidpog6H4xbdVAjEIlbCJ/Re1Ofjq1J5ESYN5NM84+b8TiMoVs7qeiqWNuid8YCGKUpuJ4JXPai63+EHP9vr0+DFxFZPEMm94f/Lo6B/2BtUB5KoC1baVItMVte9pqcjr1slf46VoeCtXmfCa3pKBQE4TZQl25pSGISHfYaiRuCZ/zo1Rd6PPOgbdaR9agHOVMugGkO55p8qWwhL7kle/Xu8oEyOiRTc/M1PAKXe5Fa1+Vz46FNtMqTlZo/Sa5ySC3QpBfhexXqbD6fO3032VRX9oNPFXuIwwjXQ0D2lGENHxxVahcqIPC4AZVDmL+9ME7k0JVDSk7zW5gQgGdEWvtCBTLahBBwbgFHoRZxlymGnMJWovcgP9cOyrjlbd/LGjd0Hp9LEaCPmMHE+yM0cgVpVUrFtTNt4O3nl14KLYCKZ+0mwkryqEF/LI= on: branch: master - condition: "$GHCVER = 8.0.1" + condition: "$GHCVER = 8.6.1" From 01ad9bf532c5f7bab07224667ad9e9d94795d7a7 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Thu, 25 Oct 2018 10:52:59 +0200 Subject: [PATCH 007/201] Checks features of travis. Tries to use ghc 8.6.2, allows it's failure and adds this branch to check whether it works. --- .travis.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd7804b..c7d4073 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,12 @@ ghc: - "8.0.2" - "8.2.2" - "8.4.4" - - "8.6.1" + - "8.6.2" + +matrix: + allow_failures: + - ghc: "8.6.2" + before_install: - travis_retry sudo apt-get update @@ -26,6 +31,7 @@ branches: only: - master - develop + - fix-travis-ghc deploy: provider: hackage @@ -34,4 +40,4 @@ deploy: secure: WQp6LHDPxGPlaFsFK1CGZaW5XSFX4+f3hLkglYFKTUzNNfmq0QXmqKJROLWrvwvTmipxguM0qZdsJTYIKJdIeECyD7dR2sZHMVpoaXgle9QkYyvoAs1o9wMbdjc/vYK4QpG9we9TPwHNalXJIkwKtoWA7IDxKQ56ln2sQLx6Qz2K/tDnq8bHNhe4U/7YRGc9K2TdiFkcimPY6BqPG/mRR8AI+q3P3YLg4x4GdDKXKtxwRdWuRQaidpog6H4xbdVAjEIlbCJ/Re1Ofjq1J5ESYN5NM84+b8TiMoVs7qeiqWNuid8YCGKUpuJ4JXPai63+EHP9vr0+DFxFZPEMm94f/Lo6B/2BtUB5KoC1baVItMVte9pqcjr1slf46VoeCtXmfCa3pKBQE4TZQl25pSGISHfYaiRuCZ/zo1Rd6PPOgbdaR9agHOVMugGkO55p8qWwhL7kle/Xu8oEyOiRTc/M1PAKXe5Fa1+Vz46FNtMqTlZo/Sa5ySC3QpBfhexXqbD6fO3032VRX9oNPFXuIwwjXQ0D2lGENHxxVahcqIPC4AZVDmL+9ME7k0JVDSk7zW5gQgGdEWvtCBTLahBBwbgFHoRZxlymGnMJWovcgP9cOyrjlbd/LGjd0Hp9LEaCPmMHE+yM0cgVpVUrFtTNt4O3nl14KLYCKZ+0mwkryqEF/LI= on: branch: master - condition: ${TRAVIS_HASKELL_VERSION}=8.4.4 \ No newline at end of file + condition: ${TRAVIS_HASKELL_VERSION}=8.4.4 From dbff6458fdf79bebe03356c45a60d775536bd4ef Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Thu, 25 Oct 2018 11:17:29 +0200 Subject: [PATCH 008/201] Removes branch from travis tests. Last step of testing for #77. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c7d4073..254f3ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,6 @@ branches: only: - master - develop - - fix-travis-ghc deploy: provider: hackage From c800503a774bacb6e42260d96acf14eb6521d711 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Sat, 3 Nov 2018 10:57:09 +0100 Subject: [PATCH 009/201] Updates haskanoid to compile with Yampa-0.13. Includes the use of the new package simple-affine-space. Refs #82. --- haskanoid.cabal | 9 +++++---- src/Data/Extra/VectorSpace.hs | 2 +- src/Objects.hs | 6 +++--- src/Physics/TwoDimensions/Collisions.hs | 2 +- src/Physics/TwoDimensions/Physics.hs | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index a2eb110..17b08a1 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -99,12 +99,13 @@ executable haskanoid -- Other library packages from which modules are imported. build-depends: base >= 4.6 && < 5, - transformers >= 0.3 && < 0.6, - mtl, + IfElse, MissingH, - Yampa >= 0.9.6 && < 0.12, + mtl, SDL, SDL-image, SDL-mixer, SDL-ttf, - IfElse + simple-affine-space, + transformers >= 0.3 && < 0.6, + Yampa >= 0.13 && < 0.14 if flag(wiimote) build-depends: hcwiid diff --git a/src/Data/Extra/VectorSpace.hs b/src/Data/Extra/VectorSpace.hs index 7b607bc..c036829 100644 --- a/src/Data/Extra/VectorSpace.hs +++ b/src/Data/Extra/VectorSpace.hs @@ -1,6 +1,6 @@ module Data.Extra.VectorSpace where -import FRP.Yampa.VectorSpace +import Data.VectorSpace limitNorm :: (Ord s, VectorSpace v s) => v -> s -> v limitNorm v mn = if norm v > mn then mn *^ normalize v else v diff --git a/src/Objects.hs b/src/Objects.hs index e100934..5c0d77b 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -1,7 +1,7 @@ -- | Game objects and collisions. module Objects where -import FRP.Yampa.VectorSpace +import Data.VectorSpace import Data.Extra.Num import Physics.TwoDimensions.Dimensions @@ -37,7 +37,7 @@ type Objects = [Object] -- TODO: Use a GADT to separate these properties in two types and guarantee a -- proper correspondence in 'Object'. data ObjectKind = Ball Double -- radius? - | Paddle Size2D + | Paddle Size2D | Block Energy Size2D | Side Side deriving (Show,Eq) @@ -77,7 +77,7 @@ type Collisions = [Collision] -- | A collision is a list of objects that collided, plus their velocities as -- modified by the collision. --- +-- -- Take into account that the same object could take part in several -- simultaneous collitions, so these velocities should be added (per object). data Collision = Collision diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index c33b061..5202ae3 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -4,7 +4,7 @@ -- between shapes. module Physics.TwoDimensions.Collisions where -import FRP.Yampa.VectorSpace as Yampa +import Data.VectorSpace import Physics.TwoDimensions.Physics -- * Collision sides diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index d567f6c..064e160 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -4,7 +4,7 @@ -- derivatives. module Physics.TwoDimensions.Physics where -import FRP.Yampa.VectorSpace as Yampa +import Data.VectorSpace import Physics.TwoDimensions.Dimensions data Shape = Rectangle Pos2D Size2D -- A corner and the whole size From 7a496e4d3540e8bc1e822ec2098aa9bc463a41e2 Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Tue, 6 Nov 2018 16:04:54 +0100 Subject: [PATCH 010/201] Changes 8.6 version. Closes #77. --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6976599..c9a2be1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ ghc: - "8.0.2" - "8.2.2" - "8.4.4" - - "8.6.2" + - "8.6.1" before_install: - travis_retry sudo apt-get update @@ -29,7 +29,7 @@ branches: matrix: allow_failures: - - ghc: "8.6.2" + - ghc: "8.6.1" deploy: provider: hackage @@ -38,4 +38,4 @@ deploy: secure: WQp6LHDPxGPlaFsFK1CGZaW5XSFX4+f3hLkglYFKTUzNNfmq0QXmqKJROLWrvwvTmipxguM0qZdsJTYIKJdIeECyD7dR2sZHMVpoaXgle9QkYyvoAs1o9wMbdjc/vYK4QpG9we9TPwHNalXJIkwKtoWA7IDxKQ56ln2sQLx6Qz2K/tDnq8bHNhe4U/7YRGc9K2TdiFkcimPY6BqPG/mRR8AI+q3P3YLg4x4GdDKXKtxwRdWuRQaidpog6H4xbdVAjEIlbCJ/Re1Ofjq1J5ESYN5NM84+b8TiMoVs7qeiqWNuid8YCGKUpuJ4JXPai63+EHP9vr0+DFxFZPEMm94f/Lo6B/2BtUB5KoC1baVItMVte9pqcjr1slf46VoeCtXmfCa3pKBQE4TZQl25pSGISHfYaiRuCZ/zo1Rd6PPOgbdaR9agHOVMugGkO55p8qWwhL7kle/Xu8oEyOiRTc/M1PAKXe5Fa1+Vz46FNtMqTlZo/Sa5ySC3QpBfhexXqbD6fO3032VRX9oNPFXuIwwjXQ0D2lGENHxxVahcqIPC4AZVDmL+9ME7k0JVDSk7zW5gQgGdEWvtCBTLahBBwbgFHoRZxlymGnMJWovcgP9cOyrjlbd/LGjd0Hp9LEaCPmMHE+yM0cgVpVUrFtTNt4O3nl14KLYCKZ+0mwkryqEF/LI= on: branch: master - condition: ${TRAVIS_HASKELL_VERSION}=8.4.4 \ No newline at end of file + condition: ${TRAVIS_HASKELL_VERSION}=8.4.4 From 6ed78cd3ccf7bd3ffb7b3f098846f83ee05ed4ee Mon Sep 17 00:00:00 2001 From: chriz-keera Date: Tue, 6 Nov 2018 16:17:31 +0100 Subject: [PATCH 011/201] Moves hands-on file. Closes #85. --- README.md | 2 +- hands-on.md => docs/hands-on.md | 0 docs/{ => slides}/ppdp2014-tutorial-4up.pdf | Bin docs/{ => slides}/ppdp2014-tutorial.pdf | Bin 4 files changed, 1 insertion(+), 1 deletion(-) rename hands-on.md => docs/hands-on.md (100%) rename docs/{ => slides}/ppdp2014-tutorial-4up.pdf (100%) rename docs/{ => slides}/ppdp2014-tutorial.pdf (100%) diff --git a/README.md b/README.md index 2ac2b12..b01dcef 100644 --- a/README.md +++ b/README.md @@ -129,7 +129,7 @@ Play](https://play.google.com/store/apps/details?id=uk.co.keera.games.magiccooki # Hands-on -In the [hands-on file](https://github.com/ivanperez-keera/haskanoid/blob/master/hands-on.md) +In the [hands-on file](https://github.com/ivanperez-keera/haskanoid/blob/develop/docs/hands-on.md) you find ideas to improve haskanoid while focussing on (game) programming related areas that you might want to dive in deeper. The areas are: functional (reactive) programming, performance, human-computer interaction and diff --git a/hands-on.md b/docs/hands-on.md similarity index 100% rename from hands-on.md rename to docs/hands-on.md diff --git a/docs/ppdp2014-tutorial-4up.pdf b/docs/slides/ppdp2014-tutorial-4up.pdf similarity index 100% rename from docs/ppdp2014-tutorial-4up.pdf rename to docs/slides/ppdp2014-tutorial-4up.pdf diff --git a/docs/ppdp2014-tutorial.pdf b/docs/slides/ppdp2014-tutorial.pdf similarity index 100% rename from docs/ppdp2014-tutorial.pdf rename to docs/slides/ppdp2014-tutorial.pdf From 7c29e2486f92210a1e94daa92202ca97e71622f5 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 9 Nov 2019 15:26:21 -0500 Subject: [PATCH 012/201] Add support for bearriver. Refs #95. Bearriver is an API-compatible Yampa implementation based on dunai and monadic stream functions. This change adds a flag to the cabal file so that it is possible to compile with bearriver (but compiles with Yampa by default). --- haskanoid.cabal | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index 17b08a1..ea25b00 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -57,6 +57,10 @@ Flag kinect Description: Enable Kinect support (with freenect) Default: True +Flag bearriver + Description: Compile with bearriver instead of Yampa + Default: False + executable haskanoid -- .hs or .lhs file containing the Main module. main-is: Main.hs @@ -104,8 +108,12 @@ executable haskanoid mtl, SDL, SDL-image, SDL-mixer, SDL-ttf, simple-affine-space, - transformers >= 0.3 && < 0.6, - Yampa >= 0.13 && < 0.14 + transformers >= 0.3 && < 0.6 + + if flag(bearriver) + build-depends: bearriver >= 0.9.6 && < 0.12 + else + build-depends: Yampa >= 0.13 && < 0.14 if flag(wiimote) build-depends: hcwiid From fbc02e198ba81ce6d06cfd483bff1ad8ce50bef0 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 9 Nov 2019 15:26:29 -0500 Subject: [PATCH 013/201] Modify recursive SF due to bad behaviour in bearriver. Refs #95. Recursive (looped) arrow expressions are not well-supported in dunai and, by extension, bearriver. This change modifies one construct in the game for an alternative without the use of rec in arrow notation. --- src/Game.hs | 61 +++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index df6eafc..96f1596 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -6,9 +6,9 @@ -- There is no randomness in the game, the only input is the user's. -- 'Controller' is an abstract representation of a basic input device with -- position information and a /fire/ button. --- +-- -- The output is defined in 'GameState', and consists of basic information --- (points, current level, etc.) and a universe of objects. +-- (points, current level, etc.) and a universe of objects. -- -- Objects are represented as Signal Functions as well ('ObjectSF'). This -- allows them to react to user input and change with time. Each object is @@ -133,9 +133,9 @@ runLevel lives level pts = loadLevel lives level pts loadingDelay -- -- The given arguments are the lives, the level, the points, the time to stay -- loading the game and the continuation. -loadLevel :: Int -> Int -> Int -> DTime -> SF a GameState -> SF a GameState +loadLevel :: Int -> Int -> Int -> DTime -> SF a GameState -> SF a GameState loadLevel lives level pts time next = switch - -- + -- (levelLoading lives level pts &&& after time ()) (\_ -> next) @@ -268,8 +268,8 @@ gamePlay' objs = loopPre ([],[],0) $ &&& arr (thd3.snd)) -- This last bit just carries the old points forward -- Adds the old point count to the newly-made points - >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) - + >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) + -- Re-arrange output, selecting (objects+dead+points, objects+collisions+points) >>> (composeOutput &&& arr (\((x,y),z) -> (x,y,z))) @@ -290,7 +290,7 @@ gamePlay' objs = loopPre ([],[],0) $ processMovement = processMovement' objs processMovement' :: ObjectSFs -> SF ObjectInput (IL ObjectOutput) - processMovement' objs = dpSwitchB + processMovement' objs = dpSwitchB objs -- Signal functions (noEvent --> arr suicidalSect) -- When necessary, remove all elements that must be removed (\sfs' f -> processMovement' (f sfs')) -- Move along! Move along! (with new state, aka. sfs) @@ -328,16 +328,16 @@ gamePlay' objs = loopPre ([],[],0) $ -- | Objects initially present: the walls, the ball, the paddle and the blocks. initialObjects :: Int -> ObjectSFs initialObjects level = listToIL $ - [ objSideRight + [ objSideRight , objSideTop , objSideLeft , objSideBottom - , objPaddle + , objPaddle , objBall ] ++ map (\p -> objBlock p (blockWidth, blockHeight)) (blockCfgs $ levels!!level) - + -- *** Ball -- | Ball @@ -347,7 +347,7 @@ initialObjects level = listToIL $ -- bounding around, until it hits the floor ('bounceAroundDetectMiss'). -- objBall :: ObjectSF -objBall = switch followPaddleDetectLaunch $ \p -> +objBall = switch followPaddleDetectLaunch $ \p -> switch (bounceAroundDetectMiss p) $ \_ -> objBall where @@ -357,13 +357,13 @@ objBall = switch followPaddleDetectLaunch $ \p -> -- the mouse button is clicked. followPaddleDetectLaunch = proc oi -> do o <- followPaddle -< oi - click <- edge -< controllerClick (userInput oi) + click <- edge -< controllerClick (userInput oi) returnA -< (o, click `tag` objectPos (outputObject o)) bounceAroundDetectMiss p = proc oi -> do o <- bouncingBall p initialBallVel -< oi miss <- collisionWithBottom -< collisions oi - returnA -< (o, miss) + returnA -< (o, miss) -- | Fires an event when the ball *enters in* a collision with the -- bottom wall. @@ -456,8 +456,8 @@ ballBounce = noEvent --> ballBounce' ballBounce' :: SF (ObjectInput, ObjectOutput) (Event (Pos2D, Vel2D)) ballBounce' = proc (ObjectInput ci cs os, o) -> do -- HN 2014-09-07: With the present strategy, need to be able to - -- detect an event directly after - -- ev <- edgeJust -< changedVelocity "ball" cs + -- detect an event directly after + -- ev <- edgeJust -< changedVelocity "ball" cs let ev = maybe noEvent Event (changedVelocity "ball" cs) returnA -< fmap (\v -> (objectPos (outputObject o), v)) ev @@ -491,7 +491,7 @@ freeBall p0 v0 = proc (ObjectInput ci cs os) -> do , collisionEnergy = 1 , displacedOnCollision = True } - + returnA -< livingObject obj -- *** Player paddle @@ -511,12 +511,13 @@ objPaddle = proc (ObjectInput ci cs os) -> do -- Try to get to the mouse position, but with a capped -- velocity. - rec - -- let v = limitNorm (20.0 *^ (refPosPaddle ci ^-^ p)) maxVNorm - -- let p = refPosPaddle ci -- (initPosPaddle ^+^) ^<< integral -< v - let v = 100.00 *^ (refPosPaddle ci ^-^ p) - p <- (initPosPaddle ^+^) ^<< integral -< v - -- let p = refPosPaddle ci + -- rec + -- -- let v = limitNorm (20.0 *^ (refPosPaddle ci ^-^ p)) maxVNorm + -- -- let p = refPosPaddle ci -- (initPosPaddle ^+^) ^<< integral -< v + -- let v = 100.00 *^ (refPosPaddle ci ^-^ p) + -- p <- (initPosPaddle ^+^) ^<< integral -< v + let p = refPosPaddle ci + v <- derivative -< p -- Use this code if you want instantaneous movement, -- particularly cool with the Wiimote, but remember to cap @@ -576,9 +577,9 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do -- use the following code in place of lives. -- -- recover <- delayEvent 5.0 -< hit - -- lives <- accumHoldBy (+) 3 -< (hit `tag` (-1) `lMerge` recover `tag` 1) - lives <- accumHoldBy (+) initlives -< (hit `tag` (-1)) - -- + -- lives <- accumHoldBy (+) 3 -< (hit `tag` (-1) `lMerge` recover `tag` 1) + lives <- accumHoldBy (+) initlives -< (hit `tag` (-1)) + -- -- let lives = 3 -- Always perfect -- Dead if out of lives. @@ -586,7 +587,7 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do dead <- edge -< isDead -- let isDead = False -- immortal blocks - returnA -< ObjectOutput + returnA -< ObjectOutput Object{ objectName = name , objectKind = Block lives (w, h) , objectPos = (x,y) @@ -613,19 +614,19 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do -- optimisation is to trigger these with every SF iteration or every rendering, -- to decrease the workload and thus the likelyhood of BTP effects. objSideRight :: ObjectSF -objSideRight = objWall "rightWall" RightSide (gameWidth, 0) +objSideRight = objWall "rightWall" RightSide (gameWidth, 0) -- | See 'objSideRight'. objSideLeft :: ObjectSF -objSideLeft = objWall "leftWall" LeftSide (0, 0) +objSideLeft = objWall "leftWall" LeftSide (0, 0) -- | See 'objSideRight'. objSideTop :: ObjectSF -objSideTop = objWall "topWall" TopSide (0, 0) +objSideTop = objWall "topWall" TopSide (0, 0) -- | See 'objSideRight'. objSideBottom :: ObjectSF -objSideBottom = objWall "bottomWall" BottomSide (0, gameHeight) +objSideBottom = objWall "bottomWall" BottomSide (0, gameHeight) -- | Generic wall builder, given a name, a side and its base -- position. From 1842c43551074c64ccb2742c1d88843451bb84e9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 25 Jan 2020 18:22:27 -0500 Subject: [PATCH 014/201] Bump version bounds of dependency on bearriver. Refs #95. Bearriver 0.13.1 was recently released, which contains many more fixes and enables evaluation with the latest release of Titan. This change bumps the upper version bound on bearriver to accept anything in the 0.13.* series, which corresponds to the same version of Yampa. --- haskanoid.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index ea25b00..4d80029 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -111,7 +111,7 @@ executable haskanoid transformers >= 0.3 && < 0.6 if flag(bearriver) - build-depends: bearriver >= 0.9.6 && < 0.12 + build-depends: bearriver >= 0.9.6 && < 0.14 else build-depends: Yampa >= 0.13 && < 0.14 From 2ba22135c0d418a7394cac373490e40db1a2db49 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 25 Jan 2020 19:21:11 -0500 Subject: [PATCH 015/201] Support stopping the game with the letter q. Refs #99. To perform benchmarking and testing it is useful to be able to stop the game. This change enables using the letter 'q' to stop the game. --- src/Input.hs | 4 +++- src/Main.hs | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 8611a30..4b841fe 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -66,6 +66,7 @@ data Controller = Controller { controllerPos :: (Double, Double) , controllerClick :: Bool , controllerPause :: Bool + , controllerQuit :: Bool } -- | Controller info at any given point, plus a pointer @@ -105,7 +106,7 @@ initializeInputDevices = do nr <- newIORef defaultInfo return $ ControllerRef (nr, dev') - where defaultInfo = Controller (0,0) False False + where defaultInfo = Controller (0,0) False False False -- | Sense from the controller, providing its current -- state. This should return a new Controller state @@ -229,6 +230,7 @@ handleEvent c e = KeyUp Keysym { symKey = SDLK_p } -> c { controllerPause = not (controllerPause c) } KeyDown Keysym { symKey = SDLK_SPACE } -> c { controllerClick = True } KeyUp Keysym { symKey = SDLK_SPACE } -> c { controllerClick = False } + KeyDown Keysym { symKey = SDLK_q } -> c { controllerQuit = True } _ -> c diff --git a/src/Main.hs b/src/Main.hs index 7353267..775c53f 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -25,6 +25,6 @@ main = do mInput <- senseInput controllerRef return (dtSecs, Just mInput) ) - (\_ e -> render res' e >> return False) - wholeGame - + (\_ (e, c) -> render res' e >> return (controllerQuit c)) + (wholeGame &&& arr id) + From c4d26ea8ba9ffd3370efe83f8cba57bf16dd9f01 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 16 Oct 2021 12:23:23 -0500 Subject: [PATCH 016/201] Update installation instructions. Refs #102. The installation instructions mention a sandbox command that no longer exists in newer versions of Cabal. They also mention a cabal haddock flags that are outdated. This commit updates the README with an installation procedure that works with a recent (3.4) version of cabal-install. [ci skip] --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b01dcef..d64ed7d 100644 --- a/README.md +++ b/README.md @@ -44,9 +44,8 @@ The game is available on [hackage](https://hackage.haskell.org/package/SpaceInva ``` $ cabal update -$ cabal sandbox init $ cabal install haskanoid -$ ./.cabal-sandbox/bin/haskanoid +$ $HOME/.cabal/bin/haskanoid ``` If you want to explore the code and possibly make changes, do the following: @@ -55,9 +54,8 @@ If you want to explore the code and possibly make changes, do the following: $ cabal update $ cabal unpack haskanoid # or git clone http://github.com/ivanperez-keera/haskanoid $ cd haskanoid-* # Game resources are here -$ cabal sandbox init $ cabal install -$ ./dist/build/haskanoid/haskanoid +$ $HOME/.cabal/bin/haskanoid ``` To play it with the wiimote, you need to run the program with the special @@ -102,11 +100,13 @@ those with: ``` $ cabal unpack haskanoid ## Or git clone this-repo $ cd haskanoid-* -$ cabal sandbox init $ cabal install --only-dependencies -$ cabal configure && cabal haddock --executables --internal +$ cabal haddock --haddock-executables --haddock-internal ``` +You may also want to add the flags `-f-wiimote` and `-f-kinect` to the cabal +commands above to install without wiimote and kinect support. + # Related projects * Yampa (http://github.com/ivanperez-keera/Yampa), the Arrowized Functional From 4d98b5f102e094c0ba96240fe8d53cc6896724e4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 17 Oct 2021 07:34:10 -0500 Subject: [PATCH 017/201] Add link to Dunai. Refs #101. Dunai should also be listed as a related project, since it can run haskanoid through bearriver. This commit adds a new entry briefly describing what Dunai is and why it's relevant. [ci skip] --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index d64ed7d..ce2b515 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,11 @@ commands above to install without wiimote and kinect support. * Yampa (http://github.com/ivanperez-keera/Yampa), the Arrowized Functional Reactive Programming implementation created by Antony Courtney and Henrik Nilsson. +* Dunai (http://github.com/ivanperez-keera/dunai), an extremely powerful +reactive programming implementation capable of doing Classic and Arrowized +Functional Reactive Programming, Reactive Programming, Stream Programming, and +others. It contains a Yampa replacement that is capable of running Haskanoid. + * hcwiid (http://github.com/ivanperez-keera/hcwiid), a wrapper around the cwiid library to communicate with Wiimotes. From ceaa9e84a03a030742cc0b6949ed28e4fc215bb3 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 09:01:50 +0000 Subject: [PATCH 018/201] Bump version bounds of Yampa and Bearriver. Refs #104. Haskanoid has an upper limit on the version of Yampa/bearriver of <0.14, which does not include any of the last two releases. To keep it up to date with Yampa and bearriver we should increase that to 0.15. This commit bumps the upper bound on both libraries to 0.15. Since these packages implement a similar API and are released in sync with the same version numbers, it makes sense that we bump their version bounds at the same time. --- haskanoid.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index 4d80029..ef46ecc 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -111,9 +111,9 @@ executable haskanoid transformers >= 0.3 && < 0.6 if flag(bearriver) - build-depends: bearriver >= 0.9.6 && < 0.14 + build-depends: bearriver >= 0.9.6 && < 0.15 else - build-depends: Yampa >= 0.13 && < 0.14 + build-depends: Yampa >= 0.13 && < 0.15 if flag(wiimote) build-depends: hcwiid From 31db41ab8f1d72134fa0dbd43f7215ec049b4eff Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 09:03:20 +0000 Subject: [PATCH 019/201] Document changes in CHANGELOG. Refs #104. --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 3cad21f..4e4b531 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2023-03-31 Ivan Perez : + * Bump version bounds of Yampa/bearriver (#104). + 2017-11-02 Ivan Perez : * Version bump (0.1.5.4). * Adds new levels. From 1ad44ce5386c2190ae4f9268dd0614e504b5d1d2 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:01:56 +0000 Subject: [PATCH 020/201] Update dist in travis config file to Bionic. Refs #105. Builds on the CI server are failing because the default image uses xenial, which is no longer supported by Postgresql (and needed for an apt-get update). This commit updates the Travis CI config file to select bionic as the distribution. Because the Haskell image doesn't accept a dist value, we remove the language field altogether and use an environment matrix to configure the selected versions of GHC and cabal to use. --- .travis.yml | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9a2be1..bec15d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,27 @@ +dist: bionic + # The following enables several GHC versions to be tested; often it's enough to # test only against the last release in a major GHC version. Feel free to omit # lines listings versions you don't need/want testing for. -language: haskell - -ghc: - - "7.6.3" - - "7.8.4" - - "7.10.3" - - "8.0.2" - - "8.2.2" - - "8.4.4" - - "8.6.1" +env: + - CABALVER=2.4 GHCVER=7.6.3 + - CABALVER=2.4 GHCVER=7.8.4 + - CABALVER=2.4 GHCVER=7.10.3 + - CABALVER=2.4 GHCVER=8.0.2 + - CABALVER=2.4 GHCVER=8.2.2 + - CABALVER=2.4 GHCVER=8.4.4 + - CABALVER=2.4 GHCVER=8.6.1 +# - CABALVER=head GHCVER=head # see section about GHC HEAD snapshots before_install: + - travis_retry sudo add-apt-repository -y ppa:hvr/ghc - travis_retry sudo apt-get update - - travis_retry sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev + - travis_retry sudo apt-get install --yes libsdl1.2-dev libsdl-image1.2-dev libsdl-ttf2.0-dev libsdl-mixer1.2-dev + - travis_retry sudo apt-get install --yes cabal-install-$CABALVER ghc-$GHCVER # see note about happy/alex + - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH + - cabal --version + - ghc --version + - travis_retry cabal update install: - travis_retry cabal install -f-wiimote -f-kinect --only-dependencies --enable-tests @@ -27,10 +34,6 @@ branches: - master - develop -matrix: - allow_failures: - - ghc: "8.6.1" - deploy: provider: hackage username: keera_studios_ci From f824122d2cb13a8be3cac3db82b279a37cf73ee3 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:02:41 +0000 Subject: [PATCH 021/201] Document changes in CHANGELOG. Refs #105. --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 4e4b531..638b4d9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ -2023-03-31 Ivan Perez : +2023-04-01 Ivan Perez : * Bump version bounds of Yampa/bearriver (#104). + * Update dist in travis config file to Bionic (#105). 2017-11-02 Ivan Perez : * Version bump (0.1.5.4). From ec51769ff5e1157c7e9768abb95dea67d9adae96 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:17:56 +0000 Subject: [PATCH 022/201] Update versions of GHC on travis. Refs #106. The travis file is using old versions of GHC, and not using new ones. This commit updates the travis to remove support for any versions prior to GHC 8.4, and adds everything else in the GHC 8 series. --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index bec15d6..6012da6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,11 @@ dist: bionic # test only against the last release in a major GHC version. Feel free to omit # lines listings versions you don't need/want testing for. env: - - CABALVER=2.4 GHCVER=7.6.3 - - CABALVER=2.4 GHCVER=7.8.4 - - CABALVER=2.4 GHCVER=7.10.3 - - CABALVER=2.4 GHCVER=8.0.2 - CABALVER=2.4 GHCVER=8.2.2 - CABALVER=2.4 GHCVER=8.4.4 - - CABALVER=2.4 GHCVER=8.6.1 + - CABALVER=2.4 GHCVER=8.6.5 + - CABALVER=2.4 GHCVER=8.8.4 + - CABALVER=2.4 GHCVER=8.10.4 # - CABALVER=head GHCVER=head # see section about GHC HEAD snapshots before_install: From 5586052534f1f5ad8ba096b798f0567350fbe696 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:18:58 +0000 Subject: [PATCH 023/201] Document changes in CHANGELOG. Refs #106. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 638b4d9..0acb860 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ 2023-04-01 Ivan Perez : * Bump version bounds of Yampa/bearriver (#104). * Update dist in travis config file to Bionic (#105). + * Update GHC versions in travis config file (#106). 2017-11-02 Ivan Perez : * Version bump (0.1.5.4). From bb1fc66e64c2d02e509db590fd6010d9b40f5e6d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:31:44 +0000 Subject: [PATCH 024/201] Enable CI builds of branches used by our development process. Refs #107. The travis file is set up to only compile master and develop, but none of the other branches we are regularly using for development. This results in an awkward where we have to activate the build on that branch but then remove the last commit before merging. This commit enables building any branches that begin with the names develop, hotfix or release. --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6012da6..82290e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,9 @@ script: branches: only: - master - - develop + - /^develop.*/ + - /^hotfix.*/ + - /^release.*/ deploy: provider: hackage From c8d8694809be10e645fe882e120cc6b321f87036 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 1 Apr 2023 17:34:04 +0000 Subject: [PATCH 025/201] Document changes in CHANGELOG. Refs #107. --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 0acb860..ec91a8a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,7 @@ * Bump version bounds of Yampa/bearriver (#104). * Update dist in travis config file to Bionic (#105). * Update GHC versions in travis config file (#106). + * Enable CI builds of branches used by our development process (#107). 2017-11-02 Ivan Perez : * Version bump (0.1.5.4). From d503d3d7f2a296960512341b0f6c26b6e4ce111f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:45:18 +0000 Subject: [PATCH 026/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Constants.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Constants.hs b/src/Constants.hs index d19fadb..827c5db 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -1,3 +1,4 @@ +-- | Game constants. module Constants where import FRP.Yampa From 5d45e33d1e1c7e305256d3f9df7fc8f6fffc9432 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:26 +0000 Subject: [PATCH 027/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Control/Extra/Monad.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Control/Extra/Monad.hs b/src/Control/Extra/Monad.hs index 9203983..7122db9 100644 --- a/src/Control/Extra/Monad.hs +++ b/src/Control/Extra/Monad.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to Control.Monad. module Control.Extra.Monad where import Control.Monad From eb8eee72fcc2690e55d7c447e848210f1c87c9eb Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:30 +0000 Subject: [PATCH 028/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Data/Extra/List.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Extra/List.hs b/src/Data/Extra/List.hs index 514f44b..c3eae11 100644 --- a/src/Data/Extra/List.hs +++ b/src/Data/Extra/List.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to Data.List. module Data.Extra.List where mapFilter :: (a -> b) -> (a -> Bool) -> [a] -> [b] From 331a79c3b70f5753473ecd041f336678249fc94e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:34 +0000 Subject: [PATCH 029/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Data/Extra/Num.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Extra/Num.hs b/src/Data/Extra/Num.hs index 828a9db..af00d71 100644 --- a/src/Data/Extra/Num.hs +++ b/src/Data/Extra/Num.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to the 'Num' typeclass. module Data.Extra.Num where ensurePos :: (Eq a, Num a) => a -> a From 6768b431e1262ee8302cdcabb7038280508e9b49 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:37 +0000 Subject: [PATCH 030/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Data/Extra/Ord.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Extra/Ord.hs b/src/Data/Extra/Ord.hs index 92e00ad..3b481a4 100644 --- a/src/Data/Extra/Ord.hs +++ b/src/Data/Extra/Ord.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to the 'Ord' typeclass. module Data.Extra.Ord where inRange :: Ord a => (a,a) -> a -> a From cb96d2084b084cb51f6ec87cd35af0b8cb70a3a5 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:41 +0000 Subject: [PATCH 031/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Data/Extra/VectorSpace.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Extra/VectorSpace.hs b/src/Data/Extra/VectorSpace.hs index c036829..adc7f2c 100644 --- a/src/Data/Extra/VectorSpace.hs +++ b/src/Data/Extra/VectorSpace.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to Data.VectorSpace. module Data.Extra.VectorSpace where import Data.VectorSpace From cf71d00866e52b31c1dd432470d910fb94b9bf75 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:44 +0000 Subject: [PATCH 032/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Display.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Display.hs b/src/Display.hs index ae30df6..ca8ffc2 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -1,3 +1,4 @@ +-- | Audio and video renderer. module Display where import Control.Applicative ((<$>)) From 71a982c7a0cf1d1cff79683857a573f80a08b6de Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:46:55 +0000 Subject: [PATCH 033/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/FRP/Extra/Yampa.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index c29d0b4..f48df52 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to FRP.Yampa. module FRP.Extra.Yampa where import Control.Arrow From 88b74ce20b517fff5511322de95c69d6a991abde Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:47:24 +0000 Subject: [PATCH 034/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Graphics/UI/Extra/FPS.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index 883713d..a3f532b 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions to calculate frames-per-second. module Graphics.UI.Extra.FPS where import Control.Monad From 3d3b912b4cf91dbda6090231bd99bbaa7e5be48e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:47:30 +0000 Subject: [PATCH 035/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Graphics/UI/Extra/SDL.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Graphics/UI/Extra/SDL.hs b/src/Graphics/UI/Extra/SDL.hs index e3e8c1d..cc3c72c 100644 --- a/src/Graphics/UI/Extra/SDL.hs +++ b/src/Graphics/UI/Extra/SDL.hs @@ -1,3 +1,4 @@ +-- | Auxiliary functions related to Graphics.UI.SDL. module Graphics.UI.Extra.SDL where import Data.IORef From 8b1af76c2346a61d1f1269175d80106489b00ce6 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:47:39 +0000 Subject: [PATCH 036/201] Add module documentation (KSG Haskell 1.3.0 - 3). Refs #103. Rule: A Haskell file consists of, in order: 1. Pragmas 2. Compilation options 3. Module haddock documentation, including any copyright notices applicable 4. Module declaration 5. Imports 6. Definitions --- src/Resources.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Resources.hs b/src/Resources.hs index b2eeff0..ea502e5 100644 --- a/src/Resources.hs +++ b/src/Resources.hs @@ -1,3 +1,4 @@ +-- | Resource specifications. module Resources where data ResourceSpec = ResourceSpec From 52f3d8448fa7fd8ae215d3c12cc4196b86725f2d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 14:59:11 +0000 Subject: [PATCH 037/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Audio.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Audio.hs b/src/Audio.hs index 0e891b8..de04220 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -1,10 +1,13 @@ --- | A layer of abstraction on top of SDL audio. +-- | +-- Copyright : (c) Keera Studios, 2010-2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- A layer of abstraction on top of SDL audio. -- -- It plays audio soundfx asynchronously (in a new thread), which means that -- programs must be compiled with the threaded Runtime System (ghc flag is -- -threaded). --- --- This module is 2010-2014 (c) Keera Studios, redistributed with permission. module Audio (Music(..), Audio(..), From c4cc2c1601046b423c9106a654fa6f36a954099e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:01 +0000 Subject: [PATCH 038/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Constants.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Constants.hs b/src/Constants.hs index 827c5db..08931ca 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -1,4 +1,9 @@ --- | Game constants. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Game constants. module Constants where import FRP.Yampa From 534f0caa34cacd2ace21559338319dfbc04d8401 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:04 +0000 Subject: [PATCH 039/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Control/Extra/Monad.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Control/Extra/Monad.hs b/src/Control/Extra/Monad.hs index 7122db9..8b64c42 100644 --- a/src/Control/Extra/Monad.hs +++ b/src/Control/Extra/Monad.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to Control.Monad. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to Control.Monad. module Control.Extra.Monad where import Control.Monad From 66b3309d129067bf68fc712a2ba2964dc46d2be0 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:08 +0000 Subject: [PATCH 040/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Data/Extra/List.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Data/Extra/List.hs b/src/Data/Extra/List.hs index c3eae11..4b1b1e9 100644 --- a/src/Data/Extra/List.hs +++ b/src/Data/Extra/List.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to Data.List. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to Data.List. module Data.Extra.List where mapFilter :: (a -> b) -> (a -> Bool) -> [a] -> [b] From 06739dad1b9eaaa3d3f74bcbe0eb1ac32bdf46ea Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:12 +0000 Subject: [PATCH 041/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Data/Extra/Num.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Data/Extra/Num.hs b/src/Data/Extra/Num.hs index af00d71..6650cc4 100644 --- a/src/Data/Extra/Num.hs +++ b/src/Data/Extra/Num.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to the 'Num' typeclass. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to the 'Num' typeclass. module Data.Extra.Num where ensurePos :: (Eq a, Num a) => a -> a From 6a95936e0cc5e9017c7acaec4dafeefd70cef3bc Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:15 +0000 Subject: [PATCH 042/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Data/Extra/Ord.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Data/Extra/Ord.hs b/src/Data/Extra/Ord.hs index 3b481a4..ec4f6b4 100644 --- a/src/Data/Extra/Ord.hs +++ b/src/Data/Extra/Ord.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to the 'Ord' typeclass. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to the 'Ord' typeclass. module Data.Extra.Ord where inRange :: Ord a => (a,a) -> a -> a From f2c56e87b560c291a223a303eb7e32caa579775c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:19 +0000 Subject: [PATCH 043/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Data/Extra/VectorSpace.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Data/Extra/VectorSpace.hs b/src/Data/Extra/VectorSpace.hs index adc7f2c..7f7b101 100644 --- a/src/Data/Extra/VectorSpace.hs +++ b/src/Data/Extra/VectorSpace.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to Data.VectorSpace. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to Data.VectorSpace. module Data.Extra.VectorSpace where import Data.VectorSpace From 5791d1e122459cca332f6e1bd7ac0132a42d2dae Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:22 +0000 Subject: [PATCH 044/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Display.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Display.hs b/src/Display.hs index ca8ffc2..adf1fb5 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -1,4 +1,9 @@ --- | Audio and video renderer. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Audio and video renderer. module Display where import Control.Applicative ((<$>)) From 463a14edf05414b3530c39fc23bbee81251bdeb7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:35 +0000 Subject: [PATCH 045/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/FRP/Extra/Yampa.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index f48df52..6286b76 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to FRP.Yampa. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to FRP.Yampa. module FRP.Extra.Yampa where import Control.Arrow From eef75ef3c9a37313bb028818e90ec6d1d492e085 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:00:44 +0000 Subject: [PATCH 046/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Game.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Game.hs b/src/Game.hs index 96f1596..aa52cd4 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -1,5 +1,10 @@ {-# LANGUAGE Arrows #-} --- | This module defines the game as a big Signal Function that transforms a +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- This module defines the game as a big Signal Function that transforms a -- Signal carrying a Input 'Controller' information into a Signal carrying -- 'GameState'. -- From 6f3c7f14ba9b718d28d0d4756b3953114b307625 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:16 +0000 Subject: [PATCH 047/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/GameCollisions.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index e0df5c0..5e5d7e2 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -1,4 +1,9 @@ --- | A very rudimentary collision system. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- A very rudimentary collision system. -- -- It compares every pair of objects, trying to determine if there is a -- collision between the two of them. From 0ecdd47b2cc7a1b284f5d1b9a7177972ab3dc816 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:32 +0000 Subject: [PATCH 048/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/GameState.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/GameState.hs b/src/GameState.hs index a74ff2e..2c0c814 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -1,4 +1,9 @@ --- | The state of the game during execution. It has two +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- The state of the game during execution. It has two -- parts: general info (level, points, etc.) and -- the actual gameplay info (objects). -- From 9cbdcb0bfcda3a35936580ab99558bc8cd21e23b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:36 +0000 Subject: [PATCH 049/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Graphics/UI/Extra/FPS.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index a3f532b..fba4f65 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions to calculate frames-per-second. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions to calculate frames-per-second. module Graphics.UI.Extra.FPS where import Control.Monad From 71b9ac69880e080fb9303fa830c26640de86e636 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:40 +0000 Subject: [PATCH 050/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Graphics/UI/Extra/SDL.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Graphics/UI/Extra/SDL.hs b/src/Graphics/UI/Extra/SDL.hs index cc3c72c..3fba552 100644 --- a/src/Graphics/UI/Extra/SDL.hs +++ b/src/Graphics/UI/Extra/SDL.hs @@ -1,4 +1,9 @@ --- | Auxiliary functions related to Graphics.UI.SDL. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Auxiliary functions related to Graphics.UI.SDL. module Graphics.UI.Extra.SDL where import Data.IORef From e85e76e7fba1624f290a877158f2024235b9759f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:43 +0000 Subject: [PATCH 051/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Input.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 4b841fe..5142583 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -1,7 +1,11 @@ {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE CPP #-} --- | Defines an abstraction for the game controller and the functions to read --- it. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Defines an abstraction for the game controller and the functions to read it. -- -- Lower-level devices replicate the higher-level API, and should accomodate to -- it. Each device should: From 85ff94e2c1b9994abfc86814757e150b4b2b430b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:01:54 +0000 Subject: [PATCH 052/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Levels.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index c46dc74..3bf4736 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -1,4 +1,9 @@ --- | Level definition +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Level definition -- -- This module includes the definition of the levels. -- From 32d4b5951b4ff9b75d7c30caf2d7ecd89538dd97 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:36 +0000 Subject: [PATCH 053/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/ObjectSF.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index 2c0a205..2319410 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -1,4 +1,9 @@ --- | Objects as signal functions. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Objects as signal functions. -- -- Live objects in the game take user input and the game universe -- and define their state in terms of that. They can remember what From e56c0cc60fc08f7bd7a6cd4b2ad54e9eb73d5fa8 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:39 +0000 Subject: [PATCH 054/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Objects.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Objects.hs b/src/Objects.hs index 5c0d77b..c20cbf9 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -1,4 +1,9 @@ --- | Game objects and collisions. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Game objects and collisions. module Objects where import Data.VectorSpace From d28079f2d03bc904469f2482911d147863d549cd Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:42 +0000 Subject: [PATCH 055/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Physics/TwoDimensions/Collisions.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index 5202ae3..191b056 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -1,4 +1,9 @@ --- | A trivial collision subsystem. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- A trivial collision subsystem. -- -- Based on the physics module, it determines the side of collision -- between shapes. From 3e359f214bb0a1967864bf65a12f8f2f939d3b93 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:45 +0000 Subject: [PATCH 056/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Physics/TwoDimensions/Dimensions.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Physics/TwoDimensions/Dimensions.hs b/src/Physics/TwoDimensions/Dimensions.hs index d4f985a..aef036e 100644 --- a/src/Physics/TwoDimensions/Dimensions.hs +++ b/src/Physics/TwoDimensions/Dimensions.hs @@ -1,5 +1,10 @@ --- | Physical dimensions used all over the game. They are just type synonyms, --- but it's best to use meaningful names to make our type signatures more +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Physical dimensions used all over the game. They are just type synonyms, but +-- it's best to use meaningful names to make our type signatures more -- meaningful. module Physics.TwoDimensions.Dimensions where From f135efa99834765e3d6a42cd0c8a5b3ee45d7dbc Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:48 +0000 Subject: [PATCH 057/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Physics/TwoDimensions/Physics.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 064e160..07cd3ee 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -1,4 +1,9 @@ --- | A very simple physics subsytem. It currently detects shape +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- A very simple physics subsytem. It currently detects shape -- overlaps only, the actual physics movement is carried out -- in Yampa itself, as it is very simple using integrals and -- derivatives. From 7d0c6c9ad7b7eef228cd948ad0cd943b54a819a9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:02:50 +0000 Subject: [PATCH 058/201] Add module copyright (KSG Haskell 1.3.0 - 3.3). Refs #103. All Haskell files must include a copyright notice in a comment. The copyright notice must be included in a format parseable by Haddock. --- src/Resources.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Resources.hs b/src/Resources.hs index ea502e5..ef450d7 100644 --- a/src/Resources.hs +++ b/src/Resources.hs @@ -1,4 +1,9 @@ --- | Resource specifications. +-- | +-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014. +-- License : See LICENSE file. +-- Maintainer : Ivan Perez +-- +-- Resource specifications. module Resources where data ResourceSpec = ResourceSpec From 97120d0c4bac23cdcfef4bb67e944c956c39bb85 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:07:38 +0000 Subject: [PATCH 059/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Audio.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Audio.hs b/src/Audio.hs index de04220..fe11215 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -19,6 +19,7 @@ module Audio stopMusic, musicPlaying) where +-- External imports import Control.Applicative ((<$>)) import Control.Monad import Control.Concurrent From 90215ac16ca893efebf3030cc09baf929eb46854 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:08:32 +0000 Subject: [PATCH 060/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Constants.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Constants.hs b/src/Constants.hs index 08931ca..4e471a0 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -6,7 +6,10 @@ -- Game constants. module Constants where +-- External imports import FRP.Yampa + +-- Internal imports import Physics.TwoDimensions.Dimensions width :: Double From e605166dd9525f40fb803ec64620c38d41683097 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:08:36 +0000 Subject: [PATCH 061/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Control/Extra/Monad.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Control/Extra/Monad.hs b/src/Control/Extra/Monad.hs index 8b64c42..15f6873 100644 --- a/src/Control/Extra/Monad.hs +++ b/src/Control/Extra/Monad.hs @@ -6,6 +6,7 @@ -- Auxiliary functions related to Control.Monad. module Control.Extra.Monad where +-- External imports import Control.Monad whileLoopM :: Monad m => m a -> (a -> Bool) -> (a -> m ()) -> m () From c9c992245940af85132fbb4a4e306071564ad914 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:08:39 +0000 Subject: [PATCH 062/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Data/Extra/VectorSpace.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Data/Extra/VectorSpace.hs b/src/Data/Extra/VectorSpace.hs index 7f7b101..397e3f8 100644 --- a/src/Data/Extra/VectorSpace.hs +++ b/src/Data/Extra/VectorSpace.hs @@ -6,6 +6,7 @@ -- Auxiliary functions related to Data.VectorSpace. module Data.Extra.VectorSpace where +-- External imports import Data.VectorSpace limitNorm :: (Ord s, VectorSpace v s) => v -> s -> v From 04708e43a9a74db1ae47c707e71624b969a49050 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:08:42 +0000 Subject: [PATCH 063/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Display.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Display.hs b/src/Display.hs index adf1fb5..2ccc500 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -6,6 +6,7 @@ -- Audio and video renderer. module Display where +-- External imports import Control.Applicative ((<$>)) import Control.Monad import Control.Monad.IfElse @@ -18,6 +19,7 @@ import Graphics.UI.SDL as SDL import qualified Graphics.UI.SDL.TTF as TTF import Graphics.UI.SDL.Image as Image +-- Internal imports import Audio import Constants import GameState From ed4717bfbcc296542c6ffa33ba29b71b55497c0c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:08:56 +0000 Subject: [PATCH 064/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/FRP/Extra/Yampa.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 6286b76..845b905 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -6,6 +6,7 @@ -- Auxiliary functions related to FRP.Yampa. module FRP.Extra.Yampa where +-- External imports import Control.Arrow import FRP.Yampa From 1c59942604a8ec4011ff3c68aa9a1aa335adbe7f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:05 +0000 Subject: [PATCH 065/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/GameCollisions.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index 5e5d7e2..d6f64bd 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -15,8 +15,11 @@ -- module GameCollisions where +-- External imports import Data.List import Data.Maybe + +-- Internal imports import Objects import Data.IdentityList import Physics.TwoDimensions.Dimensions From 9b432d28353bbc4579cd63b47c69ae0488784ebe Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:30 +0000 Subject: [PATCH 066/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/GameState.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/GameState.hs b/src/GameState.hs index 2c0c814..054232e 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -15,6 +15,7 @@ module GameState where -- import FRP.Yampa as Yampa +-- Internal imports import Objects -- | The running state is given by a bunch of 'Objects' and the current general From 1512a1066a98e94864668bcf4b83b91c082fd970 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:32 +0000 Subject: [PATCH 067/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Graphics/UI/Extra/FPS.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index fba4f65..1bd14bb 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -6,6 +6,7 @@ -- Auxiliary functions to calculate frames-per-second. module Graphics.UI.Extra.FPS where +-- External imports import Control.Monad import Data.IORef From a4bea909c50525c10808b8eec2b395f7f75944a9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:33 +0000 Subject: [PATCH 068/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Graphics/UI/Extra/SDL.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Graphics/UI/Extra/SDL.hs b/src/Graphics/UI/Extra/SDL.hs index 3fba552..022044f 100644 --- a/src/Graphics/UI/Extra/SDL.hs +++ b/src/Graphics/UI/Extra/SDL.hs @@ -6,6 +6,7 @@ -- Auxiliary functions related to Graphics.UI.SDL. module Graphics.UI.Extra.SDL where +-- External imports import Data.IORef import Graphics.UI.SDL as SDL From db304789aa58f5e4fb08cbde4a8d529e59c61c06 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:35 +0000 Subject: [PATCH 069/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Levels.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index 3bf4736..ef715ab 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -16,10 +16,12 @@ -- Together they form 'levels'. module Levels where +-- External imports import Control.Arrow ((***), first) import Data.List (nub) -import Physics.TwoDimensions.Dimensions +-- Internal imports +import Physics.TwoDimensions.Dimensions import Constants import Resources From f4ab65bb8db6f3501f445e4fe8d9509150b4d48f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:44 +0000 Subject: [PATCH 070/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Main.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index 775c53f..c57d36c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,7 +1,9 @@ +-- External imports import Control.Applicative ((<$>)) import Control.Monad.IfElse import FRP.Yampa as Yampa +-- Internal imports import Game import Display import Input From a4bfa4e88653485b13b999104c05e709a09a40e4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:46 +0000 Subject: [PATCH 071/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/ObjectSF.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index 2319410..ef7f8f0 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -16,8 +16,10 @@ -- general. module ObjectSF where +-- External imports import FRP.Yampa +-- Internal imports import Objects import Input import Data.IdentityList From 9b4310c05344cbb0e277ffb60ad7aa5a7eebe5cf Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:49 +0000 Subject: [PATCH 072/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Objects.hs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Objects.hs b/src/Objects.hs index c20cbf9..1d54f95 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -6,13 +6,17 @@ -- Game objects and collisions. module Objects where +-- External imports import Data.VectorSpace +-- Internal imports (general purpose) import Data.Extra.Num import Physics.TwoDimensions.Dimensions import Physics.TwoDimensions.Collisions import Physics.TwoDimensions.Physics +-- Internal imports +import Data.Extra.Num import Constants -- * Objects From f439119110554c41663e6a92d28ecbebcdf45d73 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:51 +0000 Subject: [PATCH 073/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Physics/TwoDimensions/Collisions.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index 191b056..7659071 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -9,7 +9,10 @@ -- between shapes. module Physics.TwoDimensions.Collisions where +-- External imports import Data.VectorSpace + +-- Internal imports import Physics.TwoDimensions.Physics -- * Collision sides From 7762874c6803c01b5a14b50f1da2b3103673321a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:09:54 +0000 Subject: [PATCH 074/201] Group imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should be grouped between external imports, external imports from the same project (but different libraries) and internal imports. When groups are used, comments must be used to indicate the nature of each group. --- src/Physics/TwoDimensions/Physics.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 07cd3ee..6b18155 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -9,7 +9,10 @@ -- derivatives. module Physics.TwoDimensions.Physics where +-- External imports import Data.VectorSpace + +-- Internal imports import Physics.TwoDimensions.Dimensions data Shape = Rectangle Pos2D Size2D -- A corner and the whole size From 47b44f1d64bd61a447b2f05cdd9f576194013dad Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:15:13 +0000 Subject: [PATCH 075/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Audio.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Audio.hs b/src/Audio.hs index fe11215..f132b65 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -21,13 +21,13 @@ module Audio -- External imports import Control.Applicative ((<$>)) -import Control.Monad import Control.Concurrent -import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer +import Control.Monad import qualified Graphics.UI.SDL.Mixer.Channels as SDL.Mixer.Channels +import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer import qualified Graphics.UI.SDL.Mixer.Music as SDL.Mixer.Music -import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types import qualified Graphics.UI.SDL.Mixer.Samples as SDL.Mixer.Samples +import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types data Music = Music { musicName :: String, unMusic :: SDL.Mixer.Types.Music } data Audio = Audio { audioName :: String, unAudio :: SDL.Mixer.Types.Chunk } From baabdd5358e40bb64a35c9804b25ec5e52aab884 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:15:43 +0000 Subject: [PATCH 076/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Display.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index 2ccc500..d4fb95a 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -10,23 +10,23 @@ module Display where import Control.Applicative ((<$>)) import Control.Monad import Control.Monad.IfElse +import Control.Monad.IO.Class import Control.Monad.Trans.Class import Control.Monad.Trans.Maybe -import Control.Monad.IO.Class import Data.IORef import Data.Maybe import Graphics.UI.SDL as SDL -import qualified Graphics.UI.SDL.TTF as TTF import Graphics.UI.SDL.Image as Image +import qualified Graphics.UI.SDL.TTF as TTF -- Internal imports import Audio import Constants import GameState -import Objects -import Resources hiding (audio) import Levels +import Objects import Paths_haskanoid +import Resources hiding (audio) -- * Initialization From 9d1f610d0d893af37de6a3d34717b416bf29ac56 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:15:55 +0000 Subject: [PATCH 077/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/GameCollisions.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index d6f64bd..ce471d3 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -20,8 +20,8 @@ import Data.List import Data.Maybe -- Internal imports -import Objects import Data.IdentityList +import Objects import Physics.TwoDimensions.Dimensions -- | Given a list of objects, it detects all the collisions between them. From cb0335c23374f69071571d78981ce46817d43b68 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:16:23 +0000 Subject: [PATCH 078/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Input.hs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 5142583..0052522 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -35,14 +35,14 @@ module Input where -- External imports +import Control.Monad import Data.IORef import Graphics.UI.SDL as SDL -import Control.Monad -- External imports (Wiimote) #ifdef wiimote -import Control.Monad(void) import Control.Monad.IfElse (awhen) +import Control.Monad(void) import Data.Maybe (fromMaybe) import System.CWiid #endif @@ -52,17 +52,16 @@ import System.CWiid import Control.Concurrent import Data.Maybe (fromJust) import Data.Vector.Storable (Vector,(!)) +import qualified Data.Vector.Storable as V import Data.Word import Freenect -import qualified Data.Vector.Storable as V #endif -- Internal imports +import Constants import Control.Extra.Monad import Graphics.UI.Extra.SDL -import Constants - -- * Game controller -- | Controller info at any given point. From 8dfa08086a701b5934e73025474a6eafb808fa04 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:16:28 +0000 Subject: [PATCH 079/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Levels.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index ef715ab..590747c 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -21,8 +21,8 @@ import Control.Arrow ((***), first) import Data.List (nub) -- Internal imports -import Physics.TwoDimensions.Dimensions import Constants +import Physics.TwoDimensions.Dimensions import Resources -- * Levels From c252ddcc57d75f989a1b98638d18333182363ae8 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:16:30 +0000 Subject: [PATCH 080/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index c57d36c..2334c2a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -4,10 +4,10 @@ import Control.Monad.IfElse import FRP.Yampa as Yampa -- Internal imports -import Game import Display -import Input +import Game import Graphics.UI.Extra.SDL +import Input -- TODO: Use MaybeT or ErrorT to report errors main :: IO () From 4855006c6ff79d5862ccb3cb70ef4433ba085f68 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:16:32 +0000 Subject: [PATCH 081/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/ObjectSF.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index ef7f8f0..e251dc2 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -20,9 +20,9 @@ module ObjectSF where import FRP.Yampa -- Internal imports -import Objects -import Input import Data.IdentityList +import Input +import Objects -- | Objects are defined as transformations that take 'ObjectInput' signals and -- return 'ObjectOutput' signals. From c8f735656da3b02dad47a6412aaa6cf1f6304f0d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:16:33 +0000 Subject: [PATCH 082/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports belonging to the same group should be listed in alphabetical order. --- src/Objects.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index 1d54f95..ba0d0bf 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -11,13 +11,13 @@ import Data.VectorSpace -- Internal imports (general purpose) import Data.Extra.Num -import Physics.TwoDimensions.Dimensions import Physics.TwoDimensions.Collisions +import Physics.TwoDimensions.Dimensions import Physics.TwoDimensions.Physics -- Internal imports -import Data.Extra.Num import Constants +import Data.Extra.Num -- * Objects From ddc5951a287ee0e56ded1b88328075cb0472ee04 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:17:58 +0000 Subject: [PATCH 083/201] Alphabetize imports (KSG Haskell 1.3.0 - 3.5). Refs #103. Elements imported from a module should be listed in alphabetical order. --- src/Levels.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index 590747c..c4a75a7 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -17,7 +17,7 @@ module Levels where -- External imports -import Control.Arrow ((***), first) +import Control.Arrow (first, (***)) import Data.List (nub) -- Internal imports From 0a1845815cc168ce808957e961a6b965a9490872 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:26:14 +0000 Subject: [PATCH 084/201] Remove redundant import (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should not be redundant (aka. no unused imports). --- src/Input.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Input.hs b/src/Input.hs index 0052522..4797b87 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -50,7 +50,6 @@ import System.CWiid -- External imports (Kinect) #ifdef kinect import Control.Concurrent -import Data.Maybe (fromJust) import Data.Vector.Storable (Vector,(!)) import qualified Data.Vector.Storable as V import Data.Word From 3d56d23917ed96daa645ac68e4d107e564c6e8d7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:26:50 +0000 Subject: [PATCH 085/201] Remove redundant import (KSG Haskell 1.3.0 - 3.5). Refs #103. Imports should not be redundant (aka. no unused imports). --- src/Objects.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Objects.hs b/src/Objects.hs index ba0d0bf..526d44b 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -17,7 +17,6 @@ import Physics.TwoDimensions.Physics -- Internal imports import Constants -import Data.Extra.Num -- * Objects From 3d15d895d7710284d64d180dafe28f6a907bb3ea Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:32:00 +0000 Subject: [PATCH 086/201] Remove unused definition (KSG Haskell 1.3.0 - 3.6.4). Refs #103. No redundant (unused) definitions should be included. --- src/Game.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index aa52cd4..e77e4fb 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -520,6 +520,10 @@ objPaddle = proc (ObjectInput ci cs os) -> do -- -- let v = limitNorm (20.0 *^ (refPosPaddle ci ^-^ p)) maxVNorm -- -- let p = refPosPaddle ci -- (initPosPaddle ^+^) ^<< integral -< v -- let v = 100.00 *^ (refPosPaddle ci ^-^ p) + -- + -- -- The initial position of the paddle, horizontally centered. + -- initPosPaddle = ((gameWidth - paddleWidth)/2, yPosPaddle) + -- -- p <- (initPosPaddle ^+^) ^<< integral -< v let p = refPosPaddle ci v <- derivative -< p @@ -553,10 +557,6 @@ refPosPaddle c = (x', yPosPaddle) (x, _) = controllerPos c x' = inRange (0, gameWidth - paddleWidth) (x - (paddleWidth/2)) --- | The initial position of the paddle, horizontally centered. -initPosPaddle :: Pos2D -initPosPaddle = ((gameWidth - paddleWidth)/2, yPosPaddle) - -- | The paddle's vertical position, at a reasonable distance from the bottom. yPosPaddle :: Double yPosPaddle = gameHeight - paddleMargin From b71530f56726c87c0f1b4c30535edebfc8ddb30b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:33:34 +0000 Subject: [PATCH 087/201] Name variable using camelCase (KSG Haskell 1.3.0 - 4.1). Refs #103. Underscore should not be used in names, except to indicate lack of effects (as the last character in the name) or in functions that export elements from other libraries via the FFI. --- src/FRP/Extra/Yampa.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 845b905..bf891b7 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -15,7 +15,7 @@ import FRP.Yampa -- holdWhen behaves normally, outputting only the b, when the second value -- is false, and it holds the last known value when the value is True. holdWhen :: b -> SF a (b,Bool) -> SF a b -holdWhen b_init sf = sf >>> holdOutput >>> hold b_init +holdWhen bInit sf = sf >>> holdOutput >>> hold bInit where holdOutput = arr (\(b,discard) -> if discard then noEvent else Event b) -- Given an occasional producer of functions From 775ec7ea7f08a7c07af6eb23caa5e7b84f1b03f8 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:48:17 +0000 Subject: [PATCH 088/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Control/Extra/Monad.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Control/Extra/Monad.hs b/src/Control/Extra/Monad.hs index 15f6873..9a6e4e9 100644 --- a/src/Control/Extra/Monad.hs +++ b/src/Control/Extra/Monad.hs @@ -21,6 +21,6 @@ foldLoopM val sense cond act = r' where r' = do s <- sense if cond s then do - val' <- act val s - foldLoopM val' sense cond act + val' <- act val s + foldLoopM val' sense cond act else return val From bcb1bc6943894aa529fc5cab83333cbe9672bb03 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:49:06 +0000 Subject: [PATCH 089/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Display.hs | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index d4fb95a..4d5bfd2 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -94,8 +94,8 @@ display resources shownState = do SDL.blitSurface bg Nothing screen $ Just rectBg hud <- createRGBSurface [SWSurface] - (round width) (round gameTop) - 32 0xFF000000 0x00FF0000 0x0000FF00 0x000000FF + (round width) (round gameTop) + 32 0xFF000000 0x00FF0000 0x0000FF00 0x000000FF paintGeneral hud resources (gameInfo shownState) let rectHud = SDL.Rect 0 0 (round width) (round gameTop) SDL.blitSurface hud Nothing screen $ Just rectHud @@ -104,8 +104,8 @@ display resources shownState = do -- The 32 is important because we are using Word32 for the masks -- FIXME: Should I use HWSurface and possibly other flags (alpha?)? surface <- createRGBSurface [SWSurface] - (round gameWidth) (round gameHeight) - 32 0xFF000000 0x00FF0000 0x0000FF00 0x000000FF + (round gameWidth) (round gameHeight) + 32 0xFF000000 0x00FF0000 0x0000FF00 0x000000FF paintGeneralMsg surface resources (gameStatus (gameInfo shownState)) mapM_ (paintObject resources surface) $ gameObjects shownState let rect = SDL.Rect (round gameLeft) (round gameTop) (round gameWidth) (round gameHeight) @@ -159,22 +159,22 @@ paintGeneralHUD screen resources over = void $ do -- | Paints a game object on a surface. paintObject :: Resources -> Surface -> Object -> IO () paintObject resources screen object = - case objectKind object of - (Paddle (w,h)) -> void $ do let bI = imgSurface $ paddleImg resources - t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) - (Block e (w,h)) -> void $ do let bI = imgSurface $ blockImage e - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) - (Ball r) -> void $ do let x' = x - round r - y' = y - round r - sz = round (2*r) - -- b <- convertSurface (imgSurface $ ballImg resources) (format) [] - let bI = imgSurface $ ballImg resources - t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x' y' sz sz) - _ -> return () + case objectKind object of + (Paddle (w,h)) -> void $ do let bI = imgSurface $ paddleImg resources + t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) + (Block e (w,h)) -> void $ do let bI = imgSurface $ blockImage e + SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) + (Ball r) -> void $ do let x' = x - round r + y' = y - round r + sz = round (2*r) + -- b <- convertSurface (imgSurface $ ballImg resources) (format) [] + let bI = imgSurface $ ballImg resources + t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x' y' sz sz) + _ -> return () where format = surfaceGetPixelFormat screen p = objectPos object x = round (fst p) @@ -290,15 +290,15 @@ updateAllResources res (GameLoading n) = do oldMusicFP = maybe "" musicName oldMusic newMusic <- if oldMusicFP == newMusicFP - then return oldMusic - else do -- Loading can fail, in which case we continue - -- with the old music - bgM <- loadMusic newMusicFP - if isNothing bgM - then do putStrLn $ "Could not load resource " ++ newMusicFP - return oldMusic - else do stopMusic - return bgM + then return oldMusic + else do -- Loading can fail, in which case we continue + -- with the old music + bgM <- loadMusic newMusicFP + if isNothing bgM + then do putStrLn $ "Could not load resource " ++ newMusicFP + return oldMusic + else do stopMusic + return bgM -- Load new background let newBgFP' = _resourceFP $ levelBg $ levels !! n From 8b9e6410c13dfe2e31322099f8d82561fc864221 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:49:23 +0000 Subject: [PATCH 090/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/FRP/Extra/Yampa.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index bf891b7..05eb187 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -16,7 +16,7 @@ import FRP.Yampa -- is false, and it holds the last known value when the value is True. holdWhen :: b -> SF a (b,Bool) -> SF a b holdWhen bInit sf = sf >>> holdOutput >>> hold bInit - where holdOutput = arr (\(b,discard) -> if discard then noEvent else Event b) + where holdOutput = arr (\(b,discard) -> if discard then noEvent else Event b) -- Given an occasional producer of functions -- and a source of info, apply the functions when they From dacddd544b2cb5626a39169dcd7be3d68a42ff52 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:49:52 +0000 Subject: [PATCH 091/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Physics/TwoDimensions/Collisions.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index 7659071..2d81301 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -37,10 +37,10 @@ oppositeSide RightSide = LeftSide -- PRE: the shapes do collide. Use 'overlapShape' to check. shapeCollisionSide :: Shape -> Shape -> Side shapeCollisionSide (Rectangle p1 s1) (Rectangle p2 s2) - | wy > hx && wy > -hx = TopSide - | wy > hx = LeftSide - | wy > -hx = RightSide - | otherwise = BottomSide + | wy > hx && wy > -hx = TopSide + | wy > hx = LeftSide + | wy > -hx = RightSide + | otherwise = BottomSide where (dx,dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) -- p1 ^-^ p2 (w,h) = 0.5 *^ (s1 ^+^ s2) wy = w * dy From 4a3a908e2f818bed6f547ae694fcde7053e850c1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:50:04 +0000 Subject: [PATCH 092/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/GameCollisions.hs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index ce471d3..b21edcd 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -32,16 +32,16 @@ import Physics.TwoDimensions.Dimensions -- detectCollisions :: IL Object -> Collisions detectCollisions = detectCollisionsH - where detectCollisionsH objsT = flattened - where -- Eliminate empty collision sets - -- TODO: why is this really necessary? - flattened = filter (\(Collision n) -> not (null n)) collisions + where detectCollisionsH objsT = flattened + where -- Eliminate empty collision sets + -- TODO: why is this really necessary? + flattened = filter (\(Collision n) -> not (null n)) collisions - -- Detect collisions between moving objects and any other objects - collisions = detectCollisions' objsT moving + -- Detect collisions between moving objects and any other objects + collisions = detectCollisions' objsT moving - -- Partition the object space between moving and static objects - (moving, _static) = partition (canCauseCollisions.snd) $ assocsIL objsT + -- Partition the object space between moving and static objects + (moving, _static) = partition (canCauseCollisions.snd) $ assocsIL objsT -- | Detect collisions between each moving object and -- every other object. @@ -60,8 +60,8 @@ detectCollisions'' objsT m = concatMap (detectCollisions''' m) (assocsIL objsT) -- determine whether the two objects do collide. detectCollisions''' :: (ILKey, Object) -> (ILKey, Object) -> [Collision] detectCollisions''' m o - | fst m == fst o = [] -- Same object -> no collision - | otherwise = maybeToList (detectCollision (snd m) (snd o)) + | fst m == fst o = [] -- Same object -> no collision + | otherwise = maybeToList (detectCollision (snd m) (snd o)) -- updateObjPos :: SF (ILKey, Object) (ILKey, Object) -- updateObjPos = proc (i,o) -> do @@ -112,13 +112,13 @@ detectCollisions''' m o -- changedVelocity :: ObjectName -> Collisions -> Maybe Vel2D changedVelocity name cs = - case concatMap (filter ((== name) . fst) . collisionData) cs of - [] -> Nothing - (_, v') : _ -> Just v' + case concatMap (filter ((== name) . fst) . collisionData) cs of + [] -> Nothing + (_, v') : _ -> Just v' - -- IP: It should be something like the following, but that doesn't - -- work: - -- vs -> Just (foldl (^+^) (0,0) (map snd vs)) + -- IP: It should be something like the following, but that doesn't + -- work: + -- vs -> Just (foldl (^+^) (0,0) (map snd vs)) -- | True if the velocity of the object has been changed by any collision. inCollision :: ObjectName -> Collisions -> Bool @@ -127,7 +127,7 @@ inCollision name cs = isJust (changedVelocity name cs) -- | True if the two objects are colliding with one another. inCollisionWith :: ObjectName -> ObjectName -> Collisions -> Bool inCollisionWith nm1 nm2 cs = any (both nm1 nm2) cs - where - both nm1 nm2 (Collision nmvs) = - any ((== nm1) . fst) nmvs - && any ((== nm2) . fst) nmvs + where + both nm1 nm2 (Collision nmvs) = + any ((== nm1) . fst) nmvs + && any ((== nm2) . fst) nmvs From e901d03c6ba3e47ff57ef72a2e3786876808f378 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:50:23 +0000 Subject: [PATCH 093/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Input.hs | 72 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 4797b87..fc9818a 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -85,30 +85,30 @@ newtype ControllerRef = -- not provide any information about its nature, abilities, etc. initializeInputDevices :: IO ControllerRef initializeInputDevices = do - let baseDev = sdlGetController + let baseDev = sdlGetController -- Fall back to mouse/kb is no kinect is present #ifdef kinect - print "Kinecting" - dev <- do kn <- kinectController - case kn of - Nothing -> return baseDev - Just kn' -> return kn' + print "Kinecting" + dev <- do kn <- kinectController + case kn of + Nothing -> return baseDev + Just kn' -> return kn' #else - let dev = baseDev + let dev = baseDev #endif -- Fall back to kinect or mouse/kb is no wiimote is present #ifdef wiimote - dev' <- do wm <- wiimoteDev - return $ fromMaybe dev wm + dev' <- do wm <- wiimoteDev + return $ fromMaybe dev wm #else - let dev' = dev + let dev' = dev #endif - nr <- newIORef defaultInfo - return $ ControllerRef (nr, dev') - where defaultInfo = Controller (0,0) False False False + nr <- newIORef defaultInfo + return $ ControllerRef (nr, dev') + where defaultInfo = Controller (0,0) False False False -- | Sense from the controller, providing its current -- state. This should return a new Controller state @@ -145,8 +145,8 @@ initializeWiimote = do wm <- cwiidOpen awhen wm (void . (`cwiidSetRptMode` 15)) -- Enable button reception, acc and IR case wm of - Nothing -> return Nothing - Just wm' -> return $ Just $ senseWiimote wm' + Nothing -> return Nothing + Just wm' -> return $ Just $ senseWiimote wm' -- ** Sensing @@ -267,18 +267,18 @@ initializeKinect screenSize = do getDepthThread :: (Double, Double) -> KinectPosRef -> IO ThreadId getDepthThread screenSize lastPos = forkIO $ do - withContext $ \context -> do - setLogLevel LogFatal context - selectSubdevices context devices - withDevice context index $ \device -> do - setDepthMode device Medium ElevenBit - setDepthCallback device $ \payload _timestamp -> do - maybe (print ".") -- Too far or too close - (updatePos lastPos) - (calculateMousePos screenSize payload) - return () - startDepth device - forever $ processEvents context + withContext $ \context -> do + setLogLevel LogFatal context + selectSubdevices context devices + withDevice context index $ \device -> do + setDepthMode device Medium ElevenBit + setDepthCallback device $ \payload _timestamp -> do + maybe (print ".") -- Too far or too close + (updatePos lastPos) + (calculateMousePos screenSize payload) + return () + startDepth device + forever $ processEvents context where devices = [Camera] index = 0 :: Integer @@ -294,15 +294,15 @@ updatePos lastPosRef newPos@(nx,ny) = do calculateMousePos :: (Double, Double) -> Vector Word16 -> Maybe (Double, Double) calculateMousePos (width, height) payload = - fmap g (findFirst payload) + fmap g (findFirst payload) where g (px,py) = (mousex, mousey) - where - pointerx = fromIntegral (640 - px) - pointery = fromIntegral py - mousex = pointerx -- pointerx * adjx - mousey = pointery -- pointery * adjy - adjx = width / 630.0 - adjy = height / 470.0 + where + pointerx = fromIntegral (640 - px) + pointery = fromIntegral py + mousex = pointerx -- pointerx * adjx + mousey = pointery -- pointery * adjy + adjx = width / 630.0 + adjy = height / 470.0 mat :: Vector Float mat = V.generate 2048 (\i -> let v :: Float @@ -310,7 +310,7 @@ mat = V.generate 2048 (\i -> let v :: Float findFirst :: Vector Word16 -> Maybe (Int, Int) findFirst vs = fmap (\v -> (v `mod` 640, v `div` 640)) i - where i = V.findIndex (\x -> mat!(fromIntegral x) < 512) vs + where i = V.findIndex (\x -> mat!(fromIntegral x) < 512) vs processPayload :: Vector Word16 -> [(Float, Int, Int)] processPayload ps = [(pval, tx, ty) | i <- [0..640*480-1] From a851b3aea3c7c04edb1b4329d1b74260dc834cb7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:50:52 +0000 Subject: [PATCH 094/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Game.hs | 300 ++++++++++++++++++++++++++-------------------------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index e77e4fb..a7778ed 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -73,9 +73,9 @@ import ObjectSF -- ('wonGame'). wholeGame :: SF Controller GameState wholeGame = switch - -- restart normal behaviour every time I'm out of lives - (canLose >>> (arr id &&& outOfLevels)) - (\_ -> wonGame) + -- restart normal behaviour every time I'm out of lives + (canLose >>> (arr id &&& outOfLevels)) + (\_ -> wonGame) -- | Detect when the last level is finished. outOfLevels :: SF GameState (Event ()) @@ -85,9 +85,9 @@ outOfLevels = arr ((>= numLevels) . gameLevel . gameInfo) >>> edge -- ('outOfLives'), in which case the game must be restarted ('restartGame'). canLose :: SF Controller GameState canLose = switch - -- retart normal behaviour every time I'm out of lives - (gameAlive >>> (arr id &&& outOfLives)) - (\_ -> restartGame) + -- retart normal behaviour every time I'm out of lives + (gameAlive >>> (arr id &&& outOfLives)) + (\_ -> restartGame) -- | Detect when the last life is lost. outOfLives :: SF GameState (Event ()) @@ -102,7 +102,7 @@ restartGame = switch -- | Produces a neutral 'GameOver' 'GameState'. gameOver :: SF a GameState gameOver = arr $ const $ - neutralGameState { gameInfo = neutralGameInfo { gameStatus = GameOver } } + neutralGameState { gameInfo = neutralGameInfo { gameStatus = GameOver } } -- | The game state is finished for 4 seconds, then the game is run again -- ('wholeGame'). @@ -113,7 +113,7 @@ wonGame = switch -- | Produces a neutral 'GameFinished' 'GameState'. gameFinished :: SF a GameState gameFinished = arr $ const $ - neutralGameState { gameInfo = neutralGameInfo { gameStatus = GameFinished } } + neutralGameState { gameInfo = neutralGameInfo { gameStatus = GameFinished } } -- | Run the game from the beginning (no points, max lives, etc.). -- @@ -131,7 +131,7 @@ gameAlive = runLevel stdLives initialLevel 0 -- continuation. runLevel :: Int -> Int -> Int -> SF Controller GameState runLevel lives level pts = loadLevel lives level pts loadingDelay - (gameWithLives lives level pts) + (gameWithLives lives level pts) -- | Unconditionally output the game in loading state ('levelLoading') for some -- time, and then ('after') switch over to the given continuation. @@ -268,63 +268,63 @@ composeGameState' lives level pts = proc (oos,dead,points) -> do -- gamePlay' :: ObjectSFs -> SF Controller (ObjectOutputs, Event (), Int) gamePlay' objs = loopPre ([],[],0) $ - -- Process physical movement and detect new collisions - ((adaptInput >>> processMovement >>> (arr elemsIL &&& detectObjectCollisions)) - &&& arr (thd3.snd)) -- This last bit just carries the old points forward - - -- Adds the old point count to the newly-made points - >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) - - -- Re-arrange output, selecting (objects+dead+points, objects+collisions+points) - >>> (composeOutput &&& arr (\((x,y),z) -> (x,y,z))) - - where - - -- Detect collisions between the ball and the bottom - -- which are the only ones that matter outside gamePlay' - composeOutput = proc ((x,y),z) -> do - y' <- collisionWithBottom -< y - returnA -< (x,y',z) - - -- Just reorder the input - adaptInput :: SF (Controller, (ObjectOutputs, Collisions, Int)) ObjectInput - adaptInput = arr (\(gi,(os,cs,pts)) -> ObjectInput gi cs (map outputObject os)) - - -- Parallely apply all object functions - processMovement :: SF ObjectInput (IL ObjectOutput) - processMovement = processMovement' objs - - processMovement' :: ObjectSFs -> SF ObjectInput (IL ObjectOutput) - processMovement' objs = dpSwitchB - objs -- Signal functions - (noEvent --> arr suicidalSect) -- When necessary, remove all elements that must be removed - (\sfs' f -> processMovement' (f sfs')) -- Move along! Move along! (with new state, aka. sfs) - - suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) - suicidalSect (_,oos) = - -- Turn every event carrying a function that transforms the - -- object signal function list into one function that performs - -- all the efects in sequence - foldl (mergeBy (.)) noEvent es - - -- Turn every object that wants to kill itself into - -- a function that removes it from the list - where es :: [Event (IL ObjectSF -> IL ObjectSF)] - es = [ harakiri oo `tag` deleteIL k - | (k,oo) <- assocsIL oos ] - - -- From the actual objects, detect which ones collide - detectObjectCollisions :: SF (IL ObjectOutput) Collisions - detectObjectCollisions = extractObjects >>> arr detectCollisions - - -- Count-points - countPoints :: Collisions -> Int - countPoints = sum . map numPoints - where numPoints (Collision cd) - | hasBall cd = countBlocks cd - | otherwise = 0 - hasBall = any ((=="ball").fst) - countBlocks = length . filter (isPrefixOf "block" . fst) + -- Process physical movement and detect new collisions + ((adaptInput >>> processMovement >>> (arr elemsIL &&& detectObjectCollisions)) + &&& arr (thd3.snd)) -- This last bit just carries the old points forward + + -- Adds the old point count to the newly-made points + >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) + + -- Re-arrange output, selecting (objects+dead+points, objects+collisions+points) + >>> (composeOutput &&& arr (\((x,y),z) -> (x,y,z))) + + where + + -- Detect collisions between the ball and the bottom + -- which are the only ones that matter outside gamePlay' + composeOutput = proc ((x,y),z) -> do + y' <- collisionWithBottom -< y + returnA -< (x,y',z) + + -- Just reorder the input + adaptInput :: SF (Controller, (ObjectOutputs, Collisions, Int)) ObjectInput + adaptInput = arr (\(gi,(os,cs,pts)) -> ObjectInput gi cs (map outputObject os)) + + -- Parallely apply all object functions + processMovement :: SF ObjectInput (IL ObjectOutput) + processMovement = processMovement' objs + + processMovement' :: ObjectSFs -> SF ObjectInput (IL ObjectOutput) + processMovement' objs = dpSwitchB + objs -- Signal functions + (noEvent --> arr suicidalSect) -- When necessary, remove all elements that must be removed + (\sfs' f -> processMovement' (f sfs')) -- Move along! Move along! (with new state, aka. sfs) + + suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) + suicidalSect (_,oos) = + -- Turn every event carrying a function that transforms the + -- object signal function list into one function that performs + -- all the efects in sequence + foldl (mergeBy (.)) noEvent es + + -- Turn every object that wants to kill itself into + -- a function that removes it from the list + where es :: [Event (IL ObjectSF -> IL ObjectSF)] + es = [ harakiri oo `tag` deleteIL k + | (k,oo) <- assocsIL oos ] + + -- From the actual objects, detect which ones collide + detectObjectCollisions :: SF (IL ObjectOutput) Collisions + detectObjectCollisions = extractObjects >>> arr detectCollisions + + -- Count-points + countPoints :: Collisions -> Int + countPoints = sum . map numPoints + where numPoints (Collision cd) + | hasBall cd = countBlocks cd + | otherwise = 0 + hasBall = any ((=="ball").fst) + countBlocks = length . filter (isPrefixOf "block" . fst) @@ -333,14 +333,14 @@ gamePlay' objs = loopPre ([],[],0) $ -- | Objects initially present: the walls, the ball, the paddle and the blocks. initialObjects :: Int -> ObjectSFs initialObjects level = listToIL $ - [ objSideRight - , objSideTop - , objSideLeft - , objSideBottom - , objPaddle - , objBall - ] - ++ map (\p -> objBlock p (blockWidth, blockHeight)) (blockCfgs $ levels!!level) + [ objSideRight + , objSideTop + , objSideLeft + , objSideBottom + , objPaddle + , objBall + ] + ++ map (\p -> objBlock p (blockWidth, blockHeight)) (blockCfgs $ levels!!level) -- *** Ball @@ -355,20 +355,20 @@ objBall :: ObjectSF objBall = switch followPaddleDetectLaunch $ \p -> switch (bounceAroundDetectMiss p) $ \_ -> objBall - where - -- Yampa's edge is used to turn the continuous - -- signal produced by controllerClick into an - -- event-carrying signal, only true the instant - -- the mouse button is clicked. - followPaddleDetectLaunch = proc oi -> do - o <- followPaddle -< oi - click <- edge -< controllerClick (userInput oi) - returnA -< (o, click `tag` objectPos (outputObject o)) - - bounceAroundDetectMiss p = proc oi -> do - o <- bouncingBall p initialBallVel -< oi - miss <- collisionWithBottom -< collisions oi - returnA -< (o, miss) + where + -- Yampa's edge is used to turn the continuous + -- signal produced by controllerClick into an + -- event-carrying signal, only true the instant + -- the mouse button is clicked. + followPaddleDetectLaunch = proc oi -> do + o <- followPaddle -< oi + click <- edge -< controllerClick (userInput oi) + returnA -< (o, click `tag` objectPos (outputObject o)) + + bounceAroundDetectMiss p = proc oi -> do + o <- bouncingBall p initialBallVel -< oi + miss <- collisionWithBottom -< collisions oi + returnA -< (o, miss) -- | Fires an event when the ball *enters in* a collision with the -- bottom wall. @@ -382,15 +382,15 @@ collisionWithBottom = inCollisionWith "ball" "bottomWall" ^>> edge -- otherwise). To avoid reacting to collisions, this ball is non-interactive. followPaddle :: ObjectSF followPaddle = arr $ \oi -> - -- Calculate ball position, midway on top of the the paddle - -- - -- This code allows for the paddle not to exist (Maybe), although that should - -- never happen in practice. - let mbPaddlePos = objectPos <$> find isPaddle (knownObjects oi) - ballPos = maybe (outOfScreen, outOfScreen) - ((paddleWidth/2, - ballHeight) ^+^) - mbPaddlePos - in ObjectOutput (inertBallAt ballPos) noEvent + -- Calculate ball position, midway on top of the the paddle + -- + -- This code allows for the paddle not to exist (Maybe), although that + -- should never happen in practice. + let mbPaddlePos = objectPos <$> find isPaddle (knownObjects oi) + ballPos = maybe (outOfScreen, outOfScreen) + ((paddleWidth/2, - ballHeight) ^+^) + mbPaddlePos + in ObjectOutput (inertBallAt ballPos) noEvent where outOfScreen = -10 inertBallAt p = Object { objectName = "ball" , objectKind = Ball ballWidth @@ -413,31 +413,31 @@ followPaddle = arr $ \oi -> -- bouncingBall :: Pos2D -> Vel2D -> ObjectSF bouncingBall p0 v0 = - switch progressAndBounce - (uncurry bouncingBall) -- Somehow it would be clearer like this: - -- \(p', v') -> bouncingBall p' v') - where - - -- Calculate the future tentative position, and - -- bounce if necessary. - -- - -- The ballBounce needs the ball SF' input (which has knowledge of - -- collisions), so we carry it parallely to the tentative new positions, - -- and then use it to detect when it's time to bounce - - -- ========================== ============================ - -- -==--------------------->==--->==- ------------------->== - -- / == == == \ / == - -- -- == == == X == - -- \ == == == / \ == - -- -==----> freeBall' ----->==--->==--------> ballBounce -->== - -- ========================== ============================ - progressAndBounce = (arr id &&& freeBall') >>> (arr snd &&& ballBounce) - - -- Position of the ball, starting from p0 with velicity v0, since the - -- time of last switching (or being fired, whatever happened last) - -- provided that no obstacles are encountered. - freeBall' = freeBall p0 v0 + switch progressAndBounce + (uncurry bouncingBall) -- Somehow it would be clearer like this: + -- \(p', v') -> bouncingBall p' v') + where + + -- Calculate the future tentative position, and + -- bounce if necessary. + -- + -- The ballBounce needs the ball SF' input (which has knowledge of + -- collisions), so we carry it parallely to the tentative new positions, + -- and then use it to detect when it's time to bounce + + -- ========================== ============================ + -- -==--------------------->==--->==- ------------------->== + -- / == == == \ / == + -- -- == == == X == + -- \ == == == / \ == + -- -==----> freeBall' ----->==--->==--------> ballBounce -->== + -- ========================== ============================ + progressAndBounce = (arr id &&& freeBall') >>> (arr snd &&& ballBounce) + + -- Position of the ball, starting from p0 with velicity v0, since the + -- time of last switching (or being fired, whatever happened last) + -- provided that no obstacles are encountered. + freeBall' = freeBall p0 v0 -- | Detect if the ball must bounce and, if so, take a snapshot of the object's -- current position and velocity. @@ -553,9 +553,9 @@ objPaddle = proc (ObjectInput ci cs os) -> do -- vertical position. refPosPaddle :: Controller -> Pos2D refPosPaddle c = (x', yPosPaddle) - where - (x, _) = controllerPos c - x' = inRange (0, gameWidth - paddleWidth) (x - (paddleWidth/2)) + where + (x, _) = controllerPos c + x' = inRange (0, gameWidth - paddleWidth) (x - (paddleWidth/2)) -- | The paddle's vertical position, at a reasonable distance from the bottom. yPosPaddle :: Double @@ -593,17 +593,17 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do -- let isDead = False -- immortal blocks returnA -< ObjectOutput - Object{ objectName = name - , objectKind = Block lives (w, h) - , objectPos = (x,y) - , objectVel = (0,0) - , objectAcc = (0,0) - , objectDead = isDead - , objectHit = isHit - , canCauseCollisions = False - , collisionEnergy = 0 - , displacedOnCollision = False - } + Object{ objectName = name + , objectKind = Block lives (w, h) + , objectPos = (x,y) + , objectVel = (0,0) + , objectAcc = (0,0) + , objectDead = isDead + , objectHit = isHit + , canCauseCollisions = False + , collisionEnergy = 0 + , displacedOnCollision = False + } dead -- *** Walls @@ -637,17 +637,17 @@ objSideBottom = objWall "bottomWall" BottomSide (0, gameHeight) -- position. objWall :: ObjectName -> Side -> Pos2D -> ObjectSF objWall name side pos = proc (ObjectInput ci cs os) -> do - let isHit = inCollision name cs - returnA -< ObjectOutput - Object { objectName = name - , objectKind = Side side - , objectPos = pos - , objectVel = (0,0) - , objectAcc = (0,0) - , objectDead = False - , objectHit = isHit - , canCauseCollisions = False - , collisionEnergy = 0 - , displacedOnCollision = False - } - noEvent + let isHit = inCollision name cs + returnA -< ObjectOutput + Object { objectName = name + , objectKind = Side side + , objectPos = pos + , objectVel = (0,0) + , objectAcc = (0,0) + , objectDead = False + , objectHit = isHit + , canCauseCollisions = False + , collisionEnergy = 0 + , displacedOnCollision = False + } + noEvent From e5d9fb11668037c5ec2be971742e0d36557fdc3a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:50:55 +0000 Subject: [PATCH 095/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Graphics/UI/Extra/FPS.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index 1bd14bb..545e97d 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -31,14 +31,14 @@ stepFPSCounter (clock, fpsRef, every) = do (lastTime, left) <- readIORef fpsRef let left' = left - 1 if left' < 0 - then do newTime <- clock - let - msf = fromIntegral (newTime - lastTime) / (fromIntegral every :: Double) - fps = 1000 / msf - do -- when (msf > 0) $ - putStrLn $ "Performance report :: Time per frame: " ++ show msf - ++ "ms, FPS: " ++ show fps - ++ ", Total running time: " ++ show newTime - writeIORef fpsRef (newTime, every) - else do writeIORef fpsRef (lastTime, left') + then do newTime <- clock + let + msf = fromIntegral (newTime - lastTime) / (fromIntegral every :: Double) + fps = 1000 / msf + do -- when (msf > 0) $ + putStrLn $ "Performance report :: Time per frame: " ++ show msf + ++ "ms, FPS: " ++ show fps + ++ ", Total running time: " ++ show newTime + writeIORef fpsRef (newTime, every) + else do writeIORef fpsRef (lastTime, left') From dd03fa1071f7e0ab386a9b1f1cc9069312080979 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:51:01 +0000 Subject: [PATCH 096/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Objects.hs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index 526d44b..2b521f6 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -36,7 +36,7 @@ data Object = Object { objectName :: ObjectName , collisionEnergy :: Double , displacedOnCollision :: Bool -- Theoretically, setting cE == 0 should suffice } - deriving (Show) + deriving (Show) type Objects = [Object] @@ -67,18 +67,18 @@ isPaddle o = case objectKind o of objShape :: Object -> Shape objShape obj = case objectKind obj of - (Ball r) -> Rectangle (p ^-^ (r,r)) (2*r, 2*r) - (Paddle s) -> Rectangle p s - (Block _ s) -> Rectangle p s - (Side s) -> sideToShape p s - where p = objectPos obj - width' = gameWidth - height' = gameHeight - d = collisionErrorMargin - sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2*d, d) - sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2*d) - sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2*d) - sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2*d, d) + (Ball r) -> Rectangle (p ^-^ (r,r)) (2*r, 2*r) + (Paddle s) -> Rectangle p s + (Block _ s) -> Rectangle p s + (Side s) -> sideToShape p s + where p = objectPos obj + width' = gameWidth + height' = gameHeight + d = collisionErrorMargin + sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2*d, d) + sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2*d) + sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2*d) + sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2*d, d) -- * Collisions type Collisions = [Collision] @@ -89,8 +89,8 @@ type Collisions = [Collision] -- Take into account that the same object could take part in several -- simultaneous collitions, so these velocities should be added (per object). data Collision = Collision - { collisionData :: [(ObjectName, Vel2D)] } -- ObjectId x Velocity - deriving Show + { collisionData :: [(ObjectName, Vel2D)] } -- ObjectId x Velocity + deriving Show -- | Detects a collision between one object and another regardless of -- everything else @@ -109,8 +109,8 @@ collisionSide obj1 obj2 = shapeCollisionSide (objShape obj1) (objShape obj2) collisionResponseObj :: Object -> Object -> Collision collisionResponseObj o1 o2 = - Collision $ - map objectToCollision [(o1, side, o2), (o2, side', o1)] + Collision $ + map objectToCollision [(o1, side, o2), (o2, side', o1)] where side = collisionSide o1 o2 side' = oppositeSide side objectReacts o = collisionEnergy o > 0 || displacedOnCollision o From c1e984d4f30dec55ed001e8b223d5bbcf47abc92 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:51:17 +0000 Subject: [PATCH 097/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Levels.hs | 382 +++++++++++++++++++++++++------------------------- 1 file changed, 191 insertions(+), 191 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index c4a75a7..0a25a0c 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -28,10 +28,10 @@ import Resources -- * Levels -- ** Level specification data LevelSpec = LevelSpec - { blockCfgs :: [(Pos2D, Int)] -- ^ Block positions and block lives - , levelBg :: ImageResource -- ^ Background image - , levelMusic :: MusicResource -- ^ Background music - } + { blockCfgs :: [(Pos2D, Int)] -- ^ Block positions and block lives + , levelBg :: ImageResource -- ^ Background image + , levelMusic :: MusicResource -- ^ Background music + } -- | Number of levels. Change this in the code to finish -- in a different level. @@ -160,13 +160,13 @@ levels = [ -- Level 0 blockDescS :: Int -> [(Pos2D, Int)] blockDescS 0 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - ] + where allBlocks :: (Enum a, Num a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + ] - blockRows :: Num a => a - blockRows = 4 + blockRows :: Num a => a + blockRows = 4 @@ -180,27 +180,27 @@ blockDescS 0 = map (first adjustPos) allBlocks -- % XXXX -- blockDescS 1 = map (first adjustPos) allBlocks - where - allBlocks :: (Enum a, Num a, Eq a, Ord a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x + y > 2) && (x + y < 10) - ] + where + allBlocks :: (Enum a, Num a, Eq a, Ord a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x + y > 2) && (x + y < 10) + ] - blockRows :: Num a => a - blockRows = 6 + blockRows :: Num a => a + blockRows = 6 -- Level 2 blockDescS 2 = map (first adjustPos) allBlocks - where - allBlocks :: (Enum a, Num a, Eq a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= y && (blockColumns - 1 - x) /= y - ] + where + allBlocks :: (Enum a, Num a, Eq a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= y && (blockColumns - 1 - x) /= y + ] - blockRows :: Num a => a - blockRows = 4 + blockRows :: Num a => a + blockRows = 4 -- Level 3 @@ -211,15 +211,15 @@ blockDescS 2 = map (first adjustPos) allBlocks -- % X X X X blockDescS 3 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , ((even x) && (odd y) || - (odd x) && (even y)) - ] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , ((even x) && (odd y) || + (odd x) && (even y)) + ] - blockRows :: Num a => a - blockRows = 4 + blockRows :: Num a => a + blockRows = 4 -- Level 4 @@ -233,16 +233,16 @@ blockDescS 3 = map (first adjustPos) allBlocks -- % XXXXXXXX blockDescS 4 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0,blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [2], odd x] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [4], even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0,blockRows - 1]] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [2], odd x] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [4], even x] - blockRows :: Num a => a - blockRows = 7 + blockRows :: Num a => a + blockRows = 7 -- Level 5 -- %%%%%%%% @@ -252,12 +252,12 @@ blockDescS 4 = map (first adjustPos) allBlocks -- % XXXXXXX blockDescS 5 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = nub $ - [((3,0), maxBlockLife),((blockColumns - 4,1), maxBlockLife)] - ++ [((2,1), maxBlockLife),((blockColumns - 3,1), maxBlockLife)] - ++ [((1,2), maxBlockLife),((blockColumns - 2,2), maxBlockLife)] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = nub $ + [((3,0), maxBlockLife),((blockColumns - 4,1), maxBlockLife)] + ++ [((2,1), maxBlockLife),((blockColumns - 3,1), maxBlockLife)] + ++ [((1,2), maxBlockLife),((blockColumns - 2,2), maxBlockLife)] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] -- Level 6 -- %%%%%%%% @@ -268,14 +268,14 @@ blockDescS 5 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 6 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1..blockRows - 2]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1]] + ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] + , y <- [1..blockRows - 2]] - blockRows :: Num a => a - blockRows = 5 + blockRows :: Num a => a + blockRows = 5 -- Level 7 @@ -288,16 +288,16 @@ blockDescS 6 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 7 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1, blockRows - 2]] - ++ [((x,y), maxBlockLife) | x <- [3,4] - , y <- [2..4]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1]] + ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] + , y <- [1, blockRows - 2]] + ++ [((x,y), maxBlockLife) | x <- [3,4] + , y <- [2..4]] - blockRows :: Num a => a - blockRows = 7 + blockRows :: Num a => a + blockRows = 7 -- Level 8 -- %%%%%%%% @@ -313,14 +313,14 @@ blockDescS 7 = map (first adjustPos) allBlocks -- % XX XXXXX blockDescS 8 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= 2, y /= 2 - ] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= 2, y /= 2 + ] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 -- Level 9 -- %%%%%%%% @@ -333,18 +333,18 @@ blockDescS 8 = map (first adjustPos) allBlocks -- % X blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [3], y <- [0..6]] - ++ [((x,y), maxBlockLife) | x <- [0..6], y <- [3]] - ++ [((x,y), maxBlockLife) | x <- [2,4], y <- [1,5]] - ++ [((x,y), maxBlockLife) | x <- [1,5], y <- [2,4]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [3], y <- [0..6]] + ++ [((x,y), maxBlockLife) | x <- [0..6], y <- [3]] + ++ [((x,y), maxBlockLife) | x <- [2,4], y <- [1,5]] + ++ [((x,y), maxBlockLife) | x <- [1,5], y <- [2,4]] - adjustHPos :: Double -> Double - adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) + adjustHPos :: Double -> Double + adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) - leftMargin :: Num a => a - leftMargin = round' ((gameWidth - (blockWidth + blockSeparation) * 7)/2) - where round' = fromIntegral . floor + leftMargin :: Num a => a + leftMargin = round' ((gameWidth - (blockWidth + blockSeparation) * 7)/2) + where round' = fromIntegral . floor -- Level 10 @@ -360,17 +360,17 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks -- % X X X blockDescS 10 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1], odd x] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1], odd x] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [midRow], even x] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 @@ -385,18 +385,18 @@ blockDescS 10 = map (first adjustPos) allBlocks -- % XX blockDescS 11 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | y <- [0..blockRows-1] - , x <- [0..(blockColumns-1) - - (2 * abs (y - midRow))] - ] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | y <- [0..blockRows-1] + , x <- [0..(blockColumns-1) + - (2 * abs (y - midRow))] + ] - blockRows :: Num a => a - blockRows = 7 + blockRows :: Num a => a + blockRows = 7 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 -- Level 12 -- %%%%%%%% @@ -409,19 +409,19 @@ blockDescS 11 = map (first adjustPos) allBlocks blockDescS 12 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0]] - ++ [((x,y), maxBlockLife) | x <- [2, blockColumns - 3] - , y <- [1, 2]] - ++ [ ((1,4), maxBlockLife) - , ((blockColumns - 2,4), maxBlockLife) - , ((0,5), maxBlockLife) - , ((blockColumns - 1,5), maxBlockLife) - ] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0]] + ++ [((x,y), maxBlockLife) | x <- [2, blockColumns - 3] + , y <- [1, 2]] + ++ [ ((1,4), maxBlockLife) + , ((blockColumns - 2,4), maxBlockLife) + , ((0,5), maxBlockLife) + , ((blockColumns - 1,5), maxBlockLife) + ] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 -- Level 13 -- X == maxBlockLife @@ -433,16 +433,16 @@ blockDescS 12 = map (first adjustPos) allBlocks -- % OXOXOXOX blockDescS 13 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), blockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , let blockLife = if even (x + y) - then maxBlockLife - else maxBlockLife - 1 - ] - - blockRows :: Num a => a - blockRows = 4 + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), blockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , let blockLife = if even (x + y) + then maxBlockLife + else maxBlockLife - 1 + ] + + blockRows :: Num a => a + blockRows = 4 -- Level 14 -- X == maxBlockLife @@ -456,28 +456,28 @@ blockDescS 13 = map (first adjustPos) allBlocks -- % YYYYYYYY blockDescS 14 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x == 0) - || (y == 0) - || (x == blockColumns - 1) - || (y == blockRows - 1)] - ++ [((x,y), maxBlockLife - 1) | x <- [1..blockColumns - 2] - , y <- [1..blockRows - 2] - , (x == 1) - || (y == 1) - || (x == blockColumns - 2) - || (y == blockRows - 2)] - ++ [((x,y), maxBlockLife) | x <- [2..blockColumns - 3] - , y <- [2..blockRows - 3] - , (x == 2) - || (y == 2) - || (x == blockColumns - 3) - || (y == blockRows - 3)] - - blockRows :: Num a => a - blockRows = 5 + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x == 0) + || (y == 0) + || (x == blockColumns - 1) + || (y == blockRows - 1)] + ++ [((x,y), maxBlockLife - 1) | x <- [1..blockColumns - 2] + , y <- [1..blockRows - 2] + , (x == 1) + || (y == 1) + || (x == blockColumns - 2) + || (y == blockRows - 2)] + ++ [((x,y), maxBlockLife) | x <- [2..blockColumns - 3] + , y <- [2..blockRows - 3] + , (x == 2) + || (y == 2) + || (x == blockColumns - 3) + || (y == blockRows - 3)] + + blockRows :: Num a => a + blockRows = 5 -- Level 15 @@ -496,21 +496,21 @@ blockDescS 14 = map (first adjustPos) allBlocks -- % T T T blockDescS 15 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..midRow], odd x] - ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] - ++ [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midRow - + 1..blockColumns - 1] - , even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..midRow], odd x] + ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [midRow], even x] + ++ [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [midRow + + 1..blockColumns - 1] + , even x] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 -- Level 16 @@ -529,28 +529,28 @@ blockDescS 15 = map (first adjustPos) allBlocks blockDescS 16 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midColumn - 1, midColumn] - , (even x && y == midColumn) - || (odd x && y == midColumn -1)] - ++ [((x,y), minBlockLife) | x <- [midColumn - 1, midColumn] - , y <- [0, 1, - blockRows - 2, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, 1, - blockRows - 2, blockRows - 1] - , x /= midColumn - 1, x /= midColumn] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [midColumn - 1, midColumn] + , (even x && y == midColumn) + || (odd x && y == midColumn -1)] + ++ [((x,y), minBlockLife) | x <- [midColumn - 1, midColumn] + , y <- [0, 1, + blockRows - 2, blockRows - 1]] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, 1, + blockRows - 2, blockRows - 1] + , x /= midColumn - 1, x /= midColumn] - blockRows :: Num a => a - blockRows = 8 + blockRows :: Num a => a + blockRows = 8 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 - midColumn :: Integral a => a - midColumn = blockColumns `div` 2 + midColumn :: Integral a => a + midColumn = blockColumns `div` 2 -- Level 17 -- maxBlockLife == X @@ -568,22 +568,22 @@ blockDescS 16 = map (first adjustPos) allBlocks -- % XXX XXXX blockDescS 17 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [3, 4] - , odd x] - ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [1, 2, - blockRows - 4, blockRows - 3] - , even x ] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - , y == 0 || x /= midColumn] - blockRows :: Num a => a - blockRows = 9 - - midColumn :: Integral a => a - midColumn = blockColumns `div` 2 + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [3, 4] + , odd x] + ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [1, 2, + blockRows - 4, blockRows - 3] + , even x ] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + , y == 0 || x /= midColumn] + blockRows :: Num a => a + blockRows = 9 + + midColumn :: Integral a => a + midColumn = blockColumns `div` 2 From a9a7d5e8899f3b67467c92a9f683b3b13e108a24 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:51:19 +0000 Subject: [PATCH 098/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/Resources.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Resources.hs b/src/Resources.hs index ef450d7..ee231f1 100644 --- a/src/Resources.hs +++ b/src/Resources.hs @@ -7,11 +7,11 @@ module Resources where data ResourceSpec = ResourceSpec - { fonts :: [FontResource] - , images :: [ImageResource] - , music :: [MusicResource] - , audio :: [AudioResource] - } + { fonts :: [FontResource] + , images :: [ImageResource] + , music :: [MusicResource] + , audio :: [AudioResource] + } type FontResource = Resource type ImageResource = Resource @@ -19,4 +19,4 @@ type MusicResource = Resource type AudioResource = Resource newtype Resource = Resource { _resourceFP :: FilePath } - deriving Eq + deriving Eq From 0a0dfb4915481b86c50577434132e747f24c490b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:51:20 +0000 Subject: [PATCH 099/201] Indent to 2 spaces (KSG Haskell 1.3.0 - 4.2). Refs #103. Each time a new expression or block-like construct is opened, the indent should increase by two spaces. When the section ends, the indent returns to the previous indent level. The indent level applies to both Haskell expressions and comments throughout the block. --- src/GameState.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GameState.hs b/src/GameState.hs index 054232e..8680449 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -69,4 +69,4 @@ data GameStatus = GamePlaying | GameOver | GameFinished | GameStarted - deriving Eq + deriving Eq From e91ec715dfbfd2f22c82fd83201e05d2ea946246 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:32:43 +0000 Subject: [PATCH 100/201] Align list by leading comma (KSG Haskell 1.3.0 - 4.2). Refs #103. For lists or tuple elements separated by commas in which each value is listed in a separate line, and when the Haskell syntax allows it, the comma must be the first character of every line but the first. --- src/Audio.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Audio.hs b/src/Audio.hs index f132b65..34e3550 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -9,15 +9,15 @@ -- programs must be compiled with the threaded Runtime System (ghc flag is -- -threaded). module Audio - (Music(..), - Audio(..), - initAudio, - loadAudio, - loadMusic, - playMusic, - playFile, - stopMusic, - musicPlaying) where + ( Music(..) + , Audio(..) + , initAudio + , loadAudio + , loadMusic + , playMusic + , playFile + , stopMusic + , musicPlaying) where -- External imports import Control.Applicative ((<$>)) From 6c123fe1be5ef77b02af4500a38922a03fc5db18 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:57:12 +0000 Subject: [PATCH 101/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Display.hs | 89 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 31 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index 4d5bfd2..a12ab6f 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -52,7 +52,7 @@ initGraphs = do -- * Rendering and Sound --- | Loads new resources, renders the game state using SDL, and adjusts music. +-- | Loads new resources, renders the game state using SDL, and adjusts music. render :: ResourceMgr -> GameState -> IO() render resourceManager shownState = do resources <- loadNewResources resourceManager shownState @@ -65,7 +65,7 @@ audio :: Resources -> GameState -> IO() audio resources shownState = do -- Start bg music if necessary playing <- musicPlaying - unless playing $ awhen (bgMusic resources) playMusic + unless playing $ awhen (bgMusic resources) playMusic -- Play object hits mapM_ (audioObject resources) $ gameObjects shownState @@ -79,7 +79,7 @@ audioObject resources object = when (objectHit object) $ -- ** Painting display :: Resources -> GameState -> IO() -display resources shownState = do +display resources shownState = do -- Obtain surface screen <- getVideoSurface @@ -108,7 +108,8 @@ display resources shownState = do 32 0xFF000000 0x00FF0000 0x0000FF00 0x000000FF paintGeneralMsg surface resources (gameStatus (gameInfo shownState)) mapM_ (paintObject resources surface) $ gameObjects shownState - let rect = SDL.Rect (round gameLeft) (round gameTop) (round gameWidth) (round gameHeight) + let rect = SDL.Rect (round gameLeft) (round gameTop) + (round gameWidth) (round gameHeight) SDL.blitSurface surface Nothing screen $ Just rect -- Double buffering @@ -123,11 +124,15 @@ paintGeneral screen resources over = void $ do paintGeneralHUD screen resources over paintGeneralMsg :: Surface -> Resources -> GameStatus -> IO () -paintGeneralMsg screen resources GamePlaying = return () -paintGeneralMsg screen resources GamePaused = paintGeneralMsg' screen resources "Paused" -paintGeneralMsg screen resources (GameLoading n) = paintGeneralMsg' screen resources ("Level " ++ show n) -paintGeneralMsg screen resources GameOver = paintGeneralMsg' screen resources "GAME OVER!!!" -paintGeneralMsg screen resources GameFinished = paintGeneralMsg' screen resources "You won!!! Well done :)" +paintGeneralMsg screen resources GamePlaying = return () +paintGeneralMsg screen resources GamePaused = + paintGeneralMsg' screen resources "Paused" +paintGeneralMsg screen resources (GameLoading n) = + paintGeneralMsg' screen resources ("Level " ++ show n) +paintGeneralMsg screen resources GameOver = + paintGeneralMsg' screen resources "GAME OVER!!!" +paintGeneralMsg screen resources GameFinished = + paintGeneralMsg' screen resources "You won!!! Well done :)" paintGeneralMsg' :: Surface -> Resources -> String -> IO () paintGeneralMsg' screen resources msg = void $ do @@ -142,38 +147,54 @@ paintGeneralMsg' screen resources msg = void $ do paintGeneralHUD :: Surface -> Resources -> GameInfo -> IO () paintGeneralHUD screen resources over = void $ do let font = unFont $ resFont resources - message1 <- TTF.renderTextSolid font ("Level: " ++ show (gameLevel over)) (SDL.Color 128 128 128) + message1 <- TTF.renderTextSolid font + ("Level: " ++ show (gameLevel over)) + (SDL.Color 128 128 128) let w1 = SDL.surfaceGetWidth message1 h1 = SDL.surfaceGetHeight message1 SDL.blitSurface message1 Nothing screen $ Just (SDL.Rect 10 10 w1 h1) - message2 <- TTF.renderTextSolid font ("Points: " ++ show (gamePoints over)) (SDL.Color 128 128 128) + message2 <- TTF.renderTextSolid font + ("Points: " ++ show (gamePoints over)) + (SDL.Color 128 128 128) let w2 = SDL.surfaceGetWidth message2 h2 = SDL.surfaceGetHeight message2 - SDL.blitSurface message2 Nothing screen $ Just (SDL.Rect 10 (10 + h2 + 5) w2 h2) - message3 <- TTF.renderTextSolid font ("Lives: " ++ show (gameLives over)) (SDL.Color 128 128 128) + SDL.blitSurface message2 Nothing screen $ + Just (SDL.Rect 10 (10 + h2 + 5) w2 h2) + message3 <- TTF.renderTextSolid font + ("Lives: " ++ show (gameLives over)) + (SDL.Color 128 128 128) let rightMargin = SDL.surfaceGetWidth screen w2 = SDL.surfaceGetWidth message3 h2 = SDL.surfaceGetHeight message3 - SDL.blitSurface message3 Nothing screen $ Just (SDL.Rect (rightMargin - 10 - w2) 10 w2 h2) + SDL.blitSurface message3 Nothing screen $ + Just (SDL.Rect (rightMargin - 10 - w2) 10 w2 h2) -- | Paints a game object on a surface. paintObject :: Resources -> Surface -> Object -> IO () paintObject resources screen object = case objectKind object of (Paddle (w,h)) -> void $ do let bI = imgSurface $ paddleImg resources - t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) + t <- mapRGB + (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x y (round w) (round h)) (Block e (w,h)) -> void $ do let bI = imgSurface $ blockImage e - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x y (round w) (round h)) + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x y (round w) (round h)) (Ball r) -> void $ do let x' = x - round r y' = y - round r sz = round (2*r) - -- b <- convertSurface (imgSurface $ ballImg resources) (format) [] + -- b <- convertSurface + -- (imgSurface $ ballImg resources) + -- (format) + -- [] let bI = imgSurface $ ballImg resources - t <- mapRGB (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x' y' sz sz) + t <- mapRGB + (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x' y' sz sz) _ -> return () where format = surfaceGetPixelFormat screen p = objectPos object @@ -212,19 +233,20 @@ data Font = Font { fontName :: String, unFont :: TTF.Font } -- This function is ad-hoc in two senses: first, because it -- has the paths to the files hard-coded inside. And second, -- because it loads the specific resources that are needed, --- not a general +-- not a general -- loadResources :: IO (Maybe ResourceMgr) loadResources = runMaybeT $ do -- Font initialization ttfOk <- lift TTF.init - + gameFont <- liftIO $ getDataFileName "data/lacuna.ttf" -- Load the fonts we need font <- liftIO $ TTF.tryOpenFont gameFont 32 -- What does the 32 do? let myFont = fmap (Font gameFont) font - blockHit <- liftIO $ loadAudio =<< getDataFileName "data/196106_aiwha_ding-cc-by.wav" + blockHit <- + liftIO $ loadAudio =<< getDataFileName "data/196106_aiwha_ding-cc-by.wav" -- bgM <- liftIO $ loadMusic "Ckotty_-_Game_Loop_11.ogg" -- bgM <- liftIO $ loadMusic "data/level0.mp3" @@ -252,10 +274,14 @@ loadResources = runMaybeT $ do -- Return Nothing or embed in Resources res <- case (myFont, blockHit) of - (Just f, Just b) -> let - in return (Resources f b Nothing ball b1 b2 b3 paddle Nothing) - _ -> do liftIO $ putStrLn "Some resources could not be loaded" - mzero + (Just f, Just b) -> return $ + Resources f b Nothing + ball b1 b2 + b3 paddle Nothing + _ -> do liftIO $ + putStrLn + "Some resources could not be loaded" + mzero liftIO $ ResourceMgr <$> newIORef (ResourceManager GameStarted res) @@ -271,7 +297,7 @@ loadNewResources mgr state = do newResources <- case newState of (GameLoading _) | newState /= oldState -> updateAllResources oldResources newState - _ -> return oldResources + _ -> return oldResources let manager' = ResourceManager { lastKnownStatus = newState , resources = newResources @@ -295,7 +321,8 @@ updateAllResources res (GameLoading n) = do -- with the old music bgM <- loadMusic newMusicFP if isNothing bgM - then do putStrLn $ "Could not load resource " ++ newMusicFP + then do putStrLn $ + "Could not load resource " ++ newMusicFP return oldMusic else do stopMusic return bgM From 472105bfbb4b3a41baf4721211619df7f73a4514 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:58:32 +0000 Subject: [PATCH 102/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/GameCollisions.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index b21edcd..0be3fe3 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -72,7 +72,8 @@ detectCollisions''' m o -- -- expected to work. Does it work well for non-linear equations? -- -- -- -- Integral only for dt interval --- actualVel <- iterFrom (\_ (v1,v2) dt _ -> (v1 * dt, v2 * dt)) (0,0) -< objectVel o +-- actualVel <- iterFrom (\_ (v1,v2) dt _ -> (v1 * dt, v2 * dt)) (0,0) +-- -< objectVel o -- -- -- Update position -- let newPos = objectPos o ^+^ actualVel From b9115526f61866924ffc50de02ce43510e8c7d66 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 15:59:44 +0000 Subject: [PATCH 103/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Game.hs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index a7778ed..02c3f8c 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -235,7 +235,8 @@ composeGameState lives level pts = futureDSwitch -- detect when a live is lost. When that happens, keep the last known game -- state. composeGameState' :: Int -> Int -> Int - -> SF (ObjectOutputs, Event (), Int) (GameState, Event GameState) + -> SF (ObjectOutputs, Event (), Int) + (GameState, Event GameState) composeGameState' lives level pts = proc (oos,dead,points) -> do -- Compose game state objects <- extractObjects -< oos @@ -269,13 +270,18 @@ composeGameState' lives level pts = proc (oos,dead,points) -> do gamePlay' :: ObjectSFs -> SF Controller (ObjectOutputs, Event (), Int) gamePlay' objs = loopPre ([],[],0) $ -- Process physical movement and detect new collisions - ((adaptInput >>> processMovement >>> (arr elemsIL &&& detectObjectCollisions)) - &&& arr (thd3.snd)) -- This last bit just carries the old points forward + ( ( adaptInput + >>> processMovement + >>> (arr elemsIL &&& detectObjectCollisions) + ) + &&& arr (thd3.snd) -- This last bit just carries the old points forward + ) -- Adds the old point count to the newly-made points >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) - -- Re-arrange output, selecting (objects+dead+points, objects+collisions+points) + -- Re-arrange output, selecting + -- (objects+dead+points, objects+collisions+points) >>> (composeOutput &&& arr (\((x,y),z) -> (x,y,z))) where @@ -288,7 +294,8 @@ gamePlay' objs = loopPre ([],[],0) $ -- Just reorder the input adaptInput :: SF (Controller, (ObjectOutputs, Collisions, Int)) ObjectInput - adaptInput = arr (\(gi,(os,cs,pts)) -> ObjectInput gi cs (map outputObject os)) + adaptInput = + arr (\(gi,(os,cs,pts)) -> ObjectInput gi cs (map outputObject os)) -- Parallely apply all object functions processMovement :: SF ObjectInput (IL ObjectOutput) @@ -296,9 +303,11 @@ gamePlay' objs = loopPre ([],[],0) $ processMovement' :: ObjectSFs -> SF ObjectInput (IL ObjectOutput) processMovement' objs = dpSwitchB - objs -- Signal functions - (noEvent --> arr suicidalSect) -- When necessary, remove all elements that must be removed - (\sfs' f -> processMovement' (f sfs')) -- Move along! Move along! (with new state, aka. sfs) + objs -- Signal functions. + (noEvent --> arr suicidalSect) -- When necessary, remove all + -- elements that must be removed. + (\sfs' f -> processMovement' (f sfs')) -- Move along! Move along! + -- (with new state, aka. sfs). suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) suicidalSect (_,oos) = @@ -340,7 +349,8 @@ initialObjects level = listToIL $ , objPaddle , objBall ] - ++ map (\p -> objBlock p (blockWidth, blockHeight)) (blockCfgs $ levels!!level) + ++ map (\p -> objBlock p (blockWidth, blockHeight)) + (blockCfgs $ levels!!level) -- *** Ball From e672b2d2ad712a987effff84089a64c1e0e5786c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:09:52 +0000 Subject: [PATCH 104/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Graphics/UI/Extra/FPS.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index 545e97d..3fc642d 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -33,7 +33,9 @@ stepFPSCounter (clock, fpsRef, every) = do if left' < 0 then do newTime <- clock let - msf = fromIntegral (newTime - lastTime) / (fromIntegral every :: Double) + msf = fromIntegral (newTime - lastTime) + / (fromIntegral every :: Double) + fps = 1000 / msf do -- when (msf > 0) $ putStrLn $ "Performance report :: Time per frame: " ++ show msf From 40edb34ae5a239e13da83b01e3c5991d94253c98 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:10:38 +0000 Subject: [PATCH 105/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Input.hs | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index fc9818a..5081fdd 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -143,7 +143,7 @@ initializeWiimote :: ControllerDev initializeWiimote = do putStrLn "Initializing WiiMote. Please press 1+2 to connect." wm <- cwiidOpen - awhen wm (void . (`cwiidSetRptMode` 15)) -- Enable button reception, acc and IR + awhen wm (void . (`cwiidSetRptMode` 15)) -- Enable button reception, acc, IR case wm of Nothing -> return Nothing Just wm' -> return $ Just $ senseWiimote wm' @@ -186,7 +186,9 @@ senseWiimote wmdev controller = do -- let isLeft = cwiidIsBtnPushed flags cwiidBtnLeft -- isRight = cwiidIsBtnPushed flags cwiidBtnRight -- (x,y) = controllerPos controller - -- x' = if isLeft then x - wiiXDiff else if isRight then x + wiiXDiff else x + -- x' | isLeft = x - wiiXDiff + -- | isRight = x + wiiXDiff + -- | otherwise = x -- x'' = inRange (0, gameWidth) x' -- pos' = (x'', y) -- wiiXDiff :: Float @@ -226,14 +228,21 @@ sdlGetController info = handleEvent :: Controller -> SDL.Event -> Controller handleEvent c e = case e of - MouseMotion x y _ _ -> c { controllerPos = (fromIntegral x, fromIntegral y)} - MouseButtonDown _ _ ButtonLeft -> c { controllerClick = True } - MouseButtonUp _ _ ButtonLeft -> c { controllerClick = False} - KeyUp Keysym { symKey = SDLK_p } -> c { controllerPause = not (controllerPause c) } - KeyDown Keysym { symKey = SDLK_SPACE } -> c { controllerClick = True } - KeyUp Keysym { symKey = SDLK_SPACE } -> c { controllerClick = False } - KeyDown Keysym { symKey = SDLK_q } -> c { controllerQuit = True } - _ -> c + MouseMotion x y _ _ -> + c { controllerPos = (fromIntegral x, fromIntegral y)} + MouseButtonDown _ _ ButtonLeft -> + c { controllerClick = True } + MouseButtonUp _ _ ButtonLeft -> + c { controllerClick = False} + KeyUp Keysym { symKey = SDLK_p } -> + c { controllerPause = not (controllerPause c) } + KeyDown Keysym { symKey = SDLK_SPACE } -> + c { controllerClick = True } + KeyUp Keysym { symKey = SDLK_SPACE } -> + c { controllerClick = False } + KeyDown Keysym { symKey = SDLK_q } -> + c { controllerQuit = True } + _ -> c -- Kinect @@ -292,7 +301,9 @@ updatePos lastPosRef newPos@(nx,ny) = do writeIORef lastPosRef (Just (mx, my)) mx `seq` my `seq` return () -calculateMousePos :: (Double, Double) -> Vector Word16 -> Maybe (Double, Double) +calculateMousePos :: (Double, Double) + -> Vector Word16 + -> Maybe (Double, Double) calculateMousePos (width, height) payload = fmap g (findFirst payload) where g (px,py) = (mousex, mousey) @@ -305,8 +316,10 @@ calculateMousePos (width, height) payload = adjy = height / 470.0 mat :: Vector Float -mat = V.generate 2048 (\i -> let v :: Float - v = ((fromIntegral i/2048.0)^3)*6.0 in v * 6.0 * 256.0) +mat = V.generate 2048 $ \i -> + let v :: Float + v = ((fromIntegral i/2048.0)^3)*6.0 + in v * 6.0 * 256.0 findFirst :: Vector Word16 -> Maybe (Int, Int) findFirst vs = fmap (\v -> (v `mod` 640, v `div` 640)) i From 7ebee856bcc7798ce69de052301e04ac69d46354 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:11:46 +0000 Subject: [PATCH 106/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Levels.hs | 52 +++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 0a25a0c..8864727 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -436,9 +436,10 @@ blockDescS 13 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] allBlocks = [((x,y), blockLife) | x <- [0..blockColumns - 1] , y <- [0..blockRows - 1] - , let blockLife = if even (x + y) - then maxBlockLife - else maxBlockLife - 1 + , let blockLife = + if even (x + y) + then maxBlockLife + else maxBlockLife - 1 ] blockRows :: Num a => a @@ -530,17 +531,18 @@ blockDescS 15 = map (first adjustPos) allBlocks blockDescS 16 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midColumn - 1, midColumn] - , (even x && y == midColumn) - || (odd x && y == midColumn -1)] - ++ [((x,y), minBlockLife) | x <- [midColumn - 1, midColumn] - , y <- [0, 1, - blockRows - 2, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, 1, - blockRows - 2, blockRows - 1] - , x /= midColumn - 1, x /= midColumn] + allBlocks = + [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [midColumn - 1, midColumn] + , (even x && y == midColumn) + || (odd x && y == midColumn -1)] + ++ [((x,y), minBlockLife) | x <- [midColumn - 1, midColumn] + , y <- [0, 1, + blockRows - 2, blockRows - 1]] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, 1, + blockRows - 2, blockRows - 1] + , x /= midColumn - 1, x /= midColumn] blockRows :: Num a => a @@ -569,16 +571,18 @@ blockDescS 16 = map (first adjustPos) allBlocks blockDescS 17 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [3, 4] - , odd x] - ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [1, 2, - blockRows - 4, blockRows - 3] - , even x ] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - , y == 0 || x /= midColumn] + allBlocks = + [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [3, 4] + , odd x] + ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [1, 2, + blockRows - 4, blockRows - 3] + , even x ] + ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + , y == 0 || x /= midColumn] + blockRows :: Num a => a blockRows = 9 From bfdba3554996a2d8d0454364adae2f540f99ea4a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:13:44 +0000 Subject: [PATCH 107/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Objects.hs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index 2b521f6..512075e 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -34,7 +34,9 @@ data Object = Object { objectName :: ObjectName , objectHit :: Bool , canCauseCollisions :: Bool , collisionEnergy :: Double - , displacedOnCollision :: Bool -- Theoretically, setting cE == 0 should suffice + , displacedOnCollision :: Bool -- Theoretically, + -- setting cE == 0 + -- should suffice. } deriving (Show) @@ -113,8 +115,17 @@ collisionResponseObj o1 o2 = map objectToCollision [(o1, side, o2), (o2, side', o1)] where side = collisionSide o1 o2 side' = oppositeSide side - objectReacts o = collisionEnergy o > 0 || displacedOnCollision o - objectToCollision (o,s,o') = (objectName o, correctVel (objectVel o ^+^ (velTrans *^ objectVel o')) (collisionEnergy o) s) + + objectReacts o = collisionEnergy o > 0 || displacedOnCollision o + + objectToCollision (o,s,o') = + ( objectName o + , correctVel + (objectVel o ^+^ (velTrans *^ objectVel o')) + (collisionEnergy o) + s + ) + correctVel (vx,vy) e TopSide = (vx, ensurePos (vy * (-e))) correctVel (vx,vy) e BottomSide = (vx, ensureNeg (vy * (-e))) correctVel (vx,vy) e LeftSide = (ensureNeg (vx * (-e)),vy) From c4baf1a2a03c3a297e24830cf52b0faf9ac43b69 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:14:22 +0000 Subject: [PATCH 108/201] Break lines longer than 80 characters (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Physics/TwoDimensions/Physics.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 6b18155..325a7b8 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -15,9 +15,9 @@ import Data.VectorSpace -- Internal imports import Physics.TwoDimensions.Dimensions -data Shape = Rectangle Pos2D Size2D -- A corner and the whole size - -- Circle Pos2D Float -- Position and radius -- NOT FOR NOW - -- SemiPlane Pos2D Float -- Position and angle of plane normal -- NFN +data Shape = Rectangle Pos2D Size2D -- A corner and the whole size + -- Circle Pos2D Float -- Position and radius -- NOT FOR NOW + -- SemiPlane Pos2D Float -- Position, angle of plane normal NFN -- | Detects if two shapes overlap. -- From 35189223062d3d8c689cce31ce3abc64d5babe54 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:07:06 +0000 Subject: [PATCH 109/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Display.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index a12ab6f..24ed7ba 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -230,11 +230,10 @@ data Image = Image { imgName :: String, imgSurface :: Surface } data Font = Font { fontName :: String, unFont :: TTF.Font } -- | Ad-hoc resource loading --- This function is ad-hoc in two senses: first, because it --- has the paths to the files hard-coded inside. And second, --- because it loads the specific resources that are needed, --- not a general -- +-- This function is ad-hoc in two senses: first, because it has the paths to +-- the files hard-coded inside. And second, because it loads the specific +-- resources that are needed, not a general loadResources :: IO (Maybe ResourceMgr) loadResources = runMaybeT $ do -- Font initialization @@ -317,8 +316,8 @@ updateAllResources res (GameLoading n) = do newMusic <- if oldMusicFP == newMusicFP then return oldMusic - else do -- Loading can fail, in which case we continue - -- with the old music + else do -- Loading can fail, in which case we continue with the + -- old music bgM <- loadMusic newMusicFP if isNothing bgM then do putStrLn $ From 7984b1ce37a93b5b1df0319568678d9279c6cecf Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 110/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/FRP/Extra/Yampa.hs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 05eb187..6ae1193 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -18,9 +18,8 @@ holdWhen :: b -> SF a (b,Bool) -> SF a b holdWhen bInit sf = sf >>> holdOutput >>> hold bInit where holdOutput = arr (\(b,discard) -> if discard then noEvent else Event b) --- Given an occasional producer of functions --- and a source of info, apply the functions when they --- exist +-- Given an occasional producer of functions and a source of info, apply the +-- functions when they exist mergeApply :: SF a b -> SF a (Event (b -> b)) -> SF a b mergeApply sf1 sf2 = (sf1 &&& sf2) >>> (arr (\(b,ef) -> event b ($ b) ef)) From 6e03580dfde74cacbc905872015c198f54a3951e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 111/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/GameCollisions.hs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index 0be3fe3..19d838b 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -26,9 +26,8 @@ import Physics.TwoDimensions.Dimensions -- | Given a list of objects, it detects all the collisions between them. -- --- Note: this is a simple n*m-complex algorithm, with n the --- number of objects and m the number of moving objects (right now, --- only 2). +-- Note: this is a simple n*m-complex algorithm, with n the number of objects +-- and m the number of moving objects (right now, only 2). -- detectCollisions :: IL Object -> Collisions detectCollisions = detectCollisionsH @@ -43,8 +42,7 @@ detectCollisions = detectCollisionsH -- Partition the object space between moving and static objects (moving, _static) = partition (canCauseCollisions.snd) $ assocsIL objsT --- | Detect collisions between each moving object and --- every other object. +-- | Detect collisions between each moving object and every other object. detectCollisions' :: IL Object -> [(ILKey, Object)] -> [Collision] detectCollisions' objsT ms = concatMap (detectCollisions'' objsT) ms @@ -92,24 +90,24 @@ detectCollisions''' m o -- The assumption is that collision detection happens globally and that the -- changed velocity is figured out for each object involved in a collision -- based on the properties of all objects involved in any specific interaction. --- That may not be how it works now, but the interface means it could work --- that way. Even more physical might be to figure out the impulsive force --- acting on each object. +-- That may not be how it works now, but the interface means it could work that +-- way. Even more physical might be to figure out the impulsive force acting on +-- each object. -- -- However, the whole collision infrastructure should be revisited. -- -- - Statefulness ("edge") might make it more robust. -- --- - Think through how collision events are going to be communicated --- to the objects themselves. Maybe an input event is the natural --- thing to do. Except then we have to be careful to avoid switching --- again immediately after one switch. +-- - Think through how collision events are going to be communicated to the +-- objects themselves. Maybe an input event is the natural thing to do. +-- Except then we have to be careful to avoid switching again immediately +-- after one switch. -- --- - Should try to avoid n^2 checks. Maybe some kind of quad-trees? --- Maybe spawning a stateful collision detector when two objects are --- getting close? Cf. the old tail-gating approach. --- - Maybe a collision should also carry the identity of the object --- one collieded with to facilitate impl. of "inCollisionWith". +-- - Should try to avoid n^2 checks. Maybe some kind of quad-trees? Maybe +-- spawning a stateful collision detector when two objects are getting close? +-- Cf. the old tail-gating approach. +-- - Maybe a collision should also carry the identity of the object one +-- collieded with to facilitate impl. of "inCollisionWith". -- changedVelocity :: ObjectName -> Collisions -> Maybe Vel2D changedVelocity name cs = @@ -117,8 +115,7 @@ changedVelocity name cs = [] -> Nothing (_, v') : _ -> Just v' - -- IP: It should be something like the following, but that doesn't - -- work: + -- IP: It should be something like the following, but that doesn't work: -- vs -> Just (foldl (^+^) (0,0) (map snd vs)) -- | True if the velocity of the object has been changed by any collision. From 4b990fcd185b5da2123254596ab0e1d8c8da07e2 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 112/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Game.hs | 102 ++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 56 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 02c3f8c..7509baf 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -18,12 +18,11 @@ -- Objects are represented as Signal Functions as well ('ObjectSF'). This -- allows them to react to user input and change with time. Each object is -- responsible for itself, but it cannot affect others: objects can watch --- others, depend on others and react to them, but they cannot /send a --- message/ or eliminate other objects. However, if you would like to --- dynamically introduce new elements in the game (for instance, falling --- powerups that the player must collect before they hit the ground) then it --- might be a good idea to allow objects not only to /kill themselves/ but --- also to spawn new object. +-- others, depend on others and react to them, but they cannot /send a message/ +-- or eliminate other objects. However, if you would like to dynamically +-- introduce new elements in the game (for instance, falling powerups that the +-- player must collect before they hit the ground) then it might be a good idea +-- to allow objects not only to /kill themselves/ but also to spawn new object. -- -- This module contains three sections: -- @@ -157,12 +156,11 @@ levelLoading lvs lvl pts = arr $ const $ -- | Start the game at a given level, with a given number of lives. -- --- It executes the normal gameplay until the level is completed. --- It then switches to the next level (remembering the current --- lives and points). +-- It executes the normal gameplay until the level is completed. It then +-- switches to the next level (remembering the current lives and points). -- --- Conditions like finishing the game or running out of lives are --- detected in 'wholeGame' and 'canLose', respectively. +-- Conditions like finishing the game or running out of lives are detected in +-- 'wholeGame' and 'canLose', respectively. -- gameWithLives :: Int -> Int -> Int -> SF Controller GameState gameWithLives numLives level pts = dSwitch @@ -186,9 +184,8 @@ isLevelCompleted = proc s -> do -- | Run the normal game. -- --- NOTE: The code includes a commented piece that detects --- a request to pause the game. Check out the code to learn how to --- implement pausing. +-- NOTE: The code includes a commented piece that detects a request to pause +-- the game. Check out the code to learn how to implement pausing. gamePlayOrPause :: Int -> Int -> Int -> SF Controller GameState gamePlayOrPause lives level pts = gamePlay lives level pts -- ((arr id) &&& (pause undefined (False --> isPaused) (mainLoop lives level))) @@ -215,8 +212,8 @@ gamePlay lives level pts = gamePlay' (initialObjects level) >>> composeGameState lives level pts -- | Based on the internal gameplay info, compose the main game state and --- detect when a live is lost. When that happens, restart this SF --- with one less life available. +-- detect when a live is lost. When that happens, restart this SF with one less +-- life available. -- -- NOTE: it will be some other SF's responsibility to determine if the player's -- run out of lives. @@ -255,9 +252,8 @@ composeGameState' lives level pts = proc (oos,dead,points) -> do -- from those objects at all times, notifying any time the ball hits the floor, -- and and of any additional points made. -- --- This works as a game loop with a post-processing step. It uses --- a well-defined initial accumulator and a traditional feedback --- loop. +-- This works as a game loop with a post-processing step. It uses a +-- well-defined initial accumulator and a traditional feedback loop. -- -- The internal accumulator holds: -- @@ -311,13 +307,13 @@ gamePlay' objs = loopPre ([],[],0) $ suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) suicidalSect (_,oos) = - -- Turn every event carrying a function that transforms the - -- object signal function list into one function that performs - -- all the efects in sequence + -- Turn every event carrying a function that transforms the object + -- signal function list into one function that performs all the efects + -- in sequence foldl (mergeBy (.)) noEvent es - -- Turn every object that wants to kill itself into - -- a function that removes it from the list + -- Turn every object that wants to kill itself into a function that + -- removes it from the list where es :: [Event (IL ObjectSF -> IL ObjectSF)] es = [ harakiri oo `tag` deleteIL k | (k,oo) <- assocsIL oos ] @@ -366,10 +362,9 @@ objBall = switch followPaddleDetectLaunch $ \p -> switch (bounceAroundDetectMiss p) $ \_ -> objBall where - -- Yampa's edge is used to turn the continuous - -- signal produced by controllerClick into an - -- event-carrying signal, only true the instant - -- the mouse button is clicked. + -- Yampa's edge is used to turn the continuous signal produced by + -- controllerClick into an event-carrying signal, only true the instant the + -- mouse button is clicked. followPaddleDetectLaunch = proc oi -> do o <- followPaddle -< oi click <- edge -< controllerClick (userInput oi) @@ -380,11 +375,10 @@ objBall = switch followPaddleDetectLaunch $ \p -> miss <- collisionWithBottom -< collisions oi returnA -< (o, miss) --- | Fires an event when the ball *enters in* a collision with the --- bottom wall. +-- | Fires an event when the ball *enters in* a collision with the bottom wall. -- --- NOTE: even if the overlap is not corrected, 'edge' makes --- the event only take place once per collision. +-- NOTE: even if the overlap is not corrected, 'edge' makes the event only take +-- place once per collision. collisionWithBottom :: SF Collisions (Event ()) collisionWithBottom = inCollisionWith "ball" "bottomWall" ^>> edge @@ -417,9 +411,9 @@ followPaddle = arr $ \oi -> -- A bouncing ball moves freely until there is a collision, then bounces and -- goes on and on. -- --- This SF needs an initial position and velocity. Every time --- there is a bounce, it takes a snapshot of the point of --- collision and corrected velocity, and starts again. +-- This SF needs an initial position and velocity. Every time there is a +-- bounce, it takes a snapshot of the point of collision and corrected +-- velocity, and starts again. -- bouncingBall :: Pos2D -> Vel2D -> ObjectSF bouncingBall p0 v0 = @@ -428,8 +422,7 @@ bouncingBall p0 v0 = -- \(p', v') -> bouncingBall p' v') where - -- Calculate the future tentative position, and - -- bounce if necessary. + -- Calculate the future tentative position, and bounce if necessary. -- -- The ballBounce needs the ball SF' input (which has knowledge of -- collisions), so we carry it parallely to the tentative new positions, @@ -455,7 +448,7 @@ bouncingBall p0 v0 = -- NOTE: To avoid infinite loops when switching, the initial input is discarded -- and never causes a bounce. This works in this game and in this particular -- case because the ball never-ever bounces immediately as fired from the --- paddle. This might not be true if a block is extremely close, if you add +-- paddle. This might not be true if a block is extremely close, if you add -- flying enemies to the game, etc. ballBounce :: SF (ObjectInput, ObjectOutput) (Event (Pos2D, Vel2D)) ballBounce = noEvent --> ballBounce' @@ -465,13 +458,13 @@ ballBounce = noEvent --> ballBounce' -- -- This does the core of the work, and does not ignore the initial input. -- --- It proceeds by detecting whether any collision affects --- the ball's velocity, and outputs a snapshot of the object --- position and the corrected velocity if necessary. +-- It proceeds by detecting whether any collision affects the ball's velocity, +-- and outputs a snapshot of the object position and the corrected velocity if +-- necessary. ballBounce' :: SF (ObjectInput, ObjectOutput) (Event (Pos2D, Vel2D)) ballBounce' = proc (ObjectInput ci cs os, o) -> do - -- HN 2014-09-07: With the present strategy, need to be able to - -- detect an event directly after + -- HN 2014-09-07: With the present strategy, need to be able to detect an + -- event directly after -- ev <- edgeJust -< changedVelocity "ball" cs let ev = maybe noEvent Event (changedVelocity "ball" cs) returnA -< fmap (\v -> (objectPos (outputObject o), v)) ev @@ -490,9 +483,8 @@ freeBall p0 v0 = proc (ObjectInput ci cs os) -> do -- Cap speed let v = limitNorm v0 maxVNorm - -- Any free moving object behaves like this (but with - -- acceleration. This should be in some FRP.NewtonianPhysics - -- module) + -- Any free moving object behaves like this (but with acceleration. This + -- should be in some FRP.NewtonianPhysics module) p <- (p0 ^+^) ^<< integral -< v let obj = Object { objectName = name @@ -523,8 +515,7 @@ objPaddle = proc (ObjectInput ci cs os) -> do let name = "paddle" let isHit = inCollision name cs - -- Try to get to the mouse position, but with a capped - -- velocity. + -- Try to get to the mouse position, but with a capped velocity. -- rec -- -- let v = limitNorm (20.0 *^ (refPosPaddle ci ^-^ p)) maxVNorm @@ -538,10 +529,9 @@ objPaddle = proc (ObjectInput ci cs os) -> do let p = refPosPaddle ci v <- derivative -< p - -- Use this code if you want instantaneous movement, - -- particularly cool with the Wiimote, but remember to cap - -- the balls velocity or you will get incredibly high - -- velocities when the paddle hits the ball. + -- Use this code if you want instantaneous movement, particularly cool with + -- the Wiimote, but remember to cap the balls velocity or you will get + -- incredibly high velocities when the paddle hits the ball. -- -- let p = refPosPaddle ci -- v <- derivative -< p @@ -559,8 +549,8 @@ objPaddle = proc (ObjectInput ci cs os) -> do , displacedOnCollision = False } --- | Follow the controller's horizontal position, keeping a constant --- vertical position. +-- | Follow the controller's horizontal position, keeping a constant vertical +-- position. refPosPaddle :: Controller -> Pos2D refPosPaddle c = (x', yPosPaddle) where @@ -588,8 +578,8 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do -- Must be hit initlives times to disappear -- - -- If you want them to "recover" or self-heal with time, - -- use the following code in place of lives. + -- If you want them to "recover" or self-heal with time, use the following + -- code in place of lives. -- -- recover <- delayEvent 5.0 -< hit -- lives <- accumHoldBy (+) 3 -< (hit `tag` (-1) `lMerge` recover `tag` 1) From 68f1dc92c848eeb6dbbcf92fda2e77058a75adaa Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 113/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/GameState.hs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/GameState.hs b/src/GameState.hs index 8680449..940c370 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -3,13 +3,11 @@ -- License : See LICENSE file. -- Maintainer : Ivan Perez -- --- The state of the game during execution. It has two --- parts: general info (level, points, etc.) and --- the actual gameplay info (objects). +-- The state of the game during execution. It has two parts: general info +-- (level, points, etc.) and the actual gameplay info (objects). -- --- Because the game is always in some running state --- (there are no menus, etc.) we assume that there's --- always some gameplay info, even though it can be +-- Because the game is always in some running state (there are no menus, etc.) +-- we assume that there's always some gameplay info, even though it can be -- empty. module GameState where @@ -37,9 +35,9 @@ neutralGameState = GameState , gameInfo = neutralGameInfo } --- | The gameinfo tells us the current game state (running, paused, etc.) --- and general information, in this case, the number of lives, the level --- and the points. +-- | The gameinfo tells us the current game state (running, paused, etc.) and +-- general information, in this case, the number of lives, the level and the +-- points. -- -- Since this info is then presented together to the users in a top panel, it -- is convenient to give this product of values a proper name. @@ -60,9 +58,9 @@ neutralGameInfo = GameInfo } -- | Possible actual game statuses. The game is always in one of these. --- Interaction and presentation depend on this. Yampa switches are --- used to jump from one to another, and the display module --- changes presentation depending on the status. +-- Interaction and presentation depend on this. Yampa switches are used to jump +-- from one to another, and the display module changes presentation depending +-- on the status. data GameStatus = GamePlaying | GamePaused | GameLoading Int From 0c71565ac57957e9765bbd3d8a0feba79bf0b492 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 114/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Input.hs | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 5081fdd..49d0bfa 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -71,18 +71,17 @@ data Controller = Controller , controllerQuit :: Bool } --- | Controller info at any given point, plus a pointer --- to poll the main device again. This is safe, --- since there is only one writer at a time (the device itself). +-- | Controller info at any given point, plus a pointer to poll the main device +-- again. This is safe, since there is only one writer at a time (the device +-- itself). newtype ControllerRef = ControllerRef (IORef Controller, Controller -> IO Controller) -- * General API --- | Initialize the available input devices. This operation --- returns a reference to a controller, which enables --- getting its state as many times as necessary. It does --- not provide any information about its nature, abilities, etc. +-- | Initialize the available input devices. This operation returns a reference +-- to a controller, which enables getting its state as many times as necessary. +-- It does not provide any information about its nature, abilities, etc. initializeInputDevices :: IO ControllerRef initializeInputDevices = do let baseDev = sdlGetController @@ -110,13 +109,11 @@ initializeInputDevices = do return $ ControllerRef (nr, dev') where defaultInfo = Controller (0,0) False False False --- | Sense from the controller, providing its current --- state. This should return a new Controller state --- if available, or the last one there was. +-- | Sense from the controller, providing its current state. This should return +-- a new Controller state if available, or the last one there was. -- --- It is assumed that the sensing function is always --- callable, and that it knows how to update the --- Controller info if necessary. +-- It is assumed that the sensing function is always callable, and that it +-- knows how to update the Controller info if necessary. senseInput :: ControllerRef -> IO Controller senseInput (ControllerRef (cref, sensor)) = do cinfo <- readIORef cref @@ -129,8 +126,8 @@ type ControllerDev = IO (Maybe (Controller -> IO Controller)) -- * WiiMote API (mid-level) #ifdef wiimote --- | The wiimote controller as defined using this --- abstract interface. See 'initializeWiimote'. +-- | The wiimote controller as defined using this abstract interface. See +-- 'initializeWiimote'. wiimoteDev :: ControllerDev wiimoteDev = initializeWiimote @@ -152,8 +149,8 @@ initializeWiimote = do -- | Sense the Wiimote and update the controller. -- --- This operation uses the IR for the controller's position, --- and the main (A) button for the click. +-- This operation uses the IR for the controller's position, and the main (A) +-- button for the click. -- -- TODO: Allow configuring the button and using other motion mechamisms -- (accelerometers). @@ -213,10 +210,9 @@ sdlMouseKB = return (Just sdlGetController) -- ** Sensing --- | Sense the SDL keyboard and mouse and update --- the controller. It only senses the mouse position, --- the primary mouse button, and the p key to pause --- the game. +-- | Sense the SDL keyboard and mouse and update the controller. It only senses +-- the mouse position, the primary mouse button, and the p key to pause the +-- game. -- -- We need a non-blocking controller-polling function. -- TODO: Check http://gameprogrammer.com/fastevents/fastevents1.html From 7b714e5dcabf1414f2272f50ba105f85a302fbb7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 115/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Levels.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 8864727..b83e0dd 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -33,8 +33,7 @@ data LevelSpec = LevelSpec , levelMusic :: MusicResource -- ^ Background music } --- | Number of levels. Change this in the code to finish --- in a different level. +-- | Number of levels. Change this in the code to finish in a different level. numLevels :: Int numLevels = length levels From c4494e4281d56b9fd95c76353edb1c2a77eb584d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 116/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/ObjectSF.hs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index e251dc2..b47f946 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -5,15 +5,14 @@ -- -- Objects as signal functions. -- --- Live objects in the game take user input and the game universe --- and define their state in terms of that. They can remember what --- happened (see Yampa's Arrow combinators, which hide continuations), --- change their behaviour (see switches in Yampa). +-- Live objects in the game take user input and the game universe and define +-- their state in terms of that. They can remember what happened (see Yampa's +-- Arrow combinators, which hide continuations), change their behaviour (see +-- switches in Yampa). -- -- They cannot affect other objects, but they can kill themselves (see --- 'harakiri'). Should you need to spawn new game elements upon --- events, you might want to change 'harakiri' to something more --- general. +-- 'harakiri'). Should you need to spawn new game elements upon events, you +-- might want to change 'harakiri' to something more general. module ObjectSF where -- External imports @@ -33,11 +32,11 @@ type ObjectSF = SF ObjectInput ObjectOutput -- ('collisions'), and the presence of any pre-existing objects -- ('knownObjects'). -- --- The reason for depending on 'Collisions' is that objects may ``die'' --- when hit. +-- The reason for depending on 'Collisions' is that objects may ``die'' when +-- hit. -- --- The reason for depending on 'Objects' is that objects may choose to --- follow other objects. +-- The reason for depending on 'Objects' is that objects may choose to follow +-- other objects. -- -- TODO: Would it be possible to depend on the specific object sfs internally -- and remove the explicit 'knownObjects'? I guess so, so long as it's possible @@ -50,8 +49,8 @@ data ObjectInput = ObjectInput , knownObjects :: Objects } --- | What we can see about each live object at each time. It's a --- snapshot of the object. +-- | What we can see about each live object at each time. It's a snapshot of +-- the object. data ObjectOutput = ObjectOutput { outputObject :: Object -- ^ The object's state (position, shape, etc.). , harakiri :: Event () -- ^ Whether the object has died (killed itself). From d631f434022e103e25949170fb73e58d7938f99a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 117/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Physics/TwoDimensions/Collisions.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index 2d81301..7cdc333 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -5,8 +5,8 @@ -- -- A trivial collision subsystem. -- --- Based on the physics module, it determines the side of collision --- between shapes. +-- Based on the physics module, it determines the side of collision between +-- shapes. module Physics.TwoDimensions.Collisions where -- External imports @@ -23,16 +23,14 @@ data Side = TopSide | BottomSide | LeftSide | RightSide -- | Opposite side during a collision. -- --- If A collides with B, the collision sides on --- A and B are always opposite. +-- If A collides with B, the collision sides on A and B are always opposite. oppositeSide :: Side -> Side oppositeSide TopSide = BottomSide oppositeSide BottomSide = TopSide oppositeSide LeftSide = RightSide oppositeSide RightSide = LeftSide --- | Calculates the collision side of a shape --- that collides against another. +-- | Calculates the collision side of a shape that collides against another. -- -- PRE: the shapes do collide. Use 'overlapShape' to check. shapeCollisionSide :: Shape -> Shape -> Side From 48a6c6bcc5468c7123e8a2b39e6ca51e8ba997a3 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:08:07 +0000 Subject: [PATCH 118/201] Re-wrap comments at 80 lines (KSG Haskell 1.3.0 - 4.3). Refs #103. We set the code limit for Haskell files at 80 characters. --- src/Physics/TwoDimensions/Physics.hs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 325a7b8..d3f0eae 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -3,10 +3,9 @@ -- License : See LICENSE file. -- Maintainer : Ivan Perez -- --- A very simple physics subsytem. It currently detects shape --- overlaps only, the actual physics movement is carried out --- in Yampa itself, as it is very simple using integrals and --- derivatives. +-- A very simple physics subsytem. It currently detects shape overlaps only, +-- the actual physics movement is carried out in Yampa itself, as it is very +-- simple using integrals and derivatives. module Physics.TwoDimensions.Physics where -- External imports @@ -21,9 +20,9 @@ data Shape = Rectangle Pos2D Size2D -- A corner and the whole size -- | Detects if two shapes overlap. -- --- Rectangles: overlap if projections on both axis overlap, --- which happens if x distance between centers is less than the sum --- of half the widths, and the analogous for y and the heights. +-- Rectangles: overlap if projections on both axis overlap, which happens if x +-- distance between centers is less than the sum of half the widths, and the +-- analogous for y and the heights. overlapShape :: Shape -> Shape -> Bool overlapShape (Rectangle p1 s1) (Rectangle p2 s2) = abs dx <= w && abs dy <= h From 2b40da265e87f97039e5ce43a6d5b3df5da3a11b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:21:26 +0000 Subject: [PATCH 119/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Audio.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Audio.hs b/src/Audio.hs index 34e3550..faa84f0 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -30,6 +30,7 @@ import qualified Graphics.UI.SDL.Mixer.Samples as SDL.Mixer.Samples import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types data Music = Music { musicName :: String, unMusic :: SDL.Mixer.Types.Music } + data Audio = Audio { audioName :: String, unAudio :: SDL.Mixer.Types.Chunk } -- | Initialize the audio subsystem. From c3cf2e55c53d93623e364aae147ffd258e9e574b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:22:01 +0000 Subject: [PATCH 120/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Physics/TwoDimensions/Dimensions.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Physics/TwoDimensions/Dimensions.hs b/src/Physics/TwoDimensions/Dimensions.hs index aef036e..4a6cde7 100644 --- a/src/Physics/TwoDimensions/Dimensions.hs +++ b/src/Physics/TwoDimensions/Dimensions.hs @@ -9,6 +9,9 @@ module Physics.TwoDimensions.Dimensions where type Size2D = (Double, Double) + type Pos2D = (Double, Double) + type Vel2D = (Double, Double) + type Acc2D = (Double, Double) From 2e05866ad23a5a1f30b0cdce6adda2ae12fd1d2d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:22:05 +0000 Subject: [PATCH 121/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Input.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Input.hs b/src/Input.hs index 49d0bfa..e1b862a 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -262,6 +262,7 @@ kinectWidth = 640 kinectHeight = 480 type KinectPosRef = IORef KinectPos + type KinectPos = Maybe (Double, Double) initializeKinect :: (Double, Double) -> IO KinectPosRef From b8855dba587363eefeb7271d837f6429e0a93096 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:22:07 +0000 Subject: [PATCH 122/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Display.hs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Display.hs b/src/Display.hs index 24ed7ba..a0092ac 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -227,6 +227,7 @@ data Resources = Resources } data Image = Image { imgName :: String, imgSurface :: Surface } + data Font = Font { fontName :: String, unFont :: TTF.Font } -- | Ad-hoc resource loading From fe4826e3c1dd88d49897509ab556f3004202ded7 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:22:10 +0000 Subject: [PATCH 123/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Resources.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Resources.hs b/src/Resources.hs index ee231f1..f5e9d99 100644 --- a/src/Resources.hs +++ b/src/Resources.hs @@ -14,8 +14,11 @@ data ResourceSpec = ResourceSpec } type FontResource = Resource + type ImageResource = Resource + type MusicResource = Resource + type AudioResource = Resource newtype Resource = Resource { _resourceFP :: FilePath } From 603cd143c2cfc3b243caebbc3108a0c2fbafe1c1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:22:15 +0000 Subject: [PATCH 124/201] Introduce vertical space between definitions (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Constants.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Constants.hs b/src/Constants.hs index 4e471a0..8665fb2 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -14,16 +14,19 @@ import Physics.TwoDimensions.Dimensions width :: Double width = 640 + height :: Double height = 600 gameTop :: Double gameTop = 100 + gameLeft :: Double gameLeft = 0 gameWidth :: Double gameWidth = width + gameHeight :: Double gameHeight = height - gameTop @@ -33,20 +36,27 @@ loadingDelay = 2 -- seconds paddleWidth, paddleHeight :: Double paddleWidth = 104 paddleHeight = 24 + paddleMargin :: Double paddleMargin = 50 + ballWidth, ballHeight :: Double ballWidth = 10 ballHeight = 10 + ballMargin :: Double ballMargin = 30 + blockWidth, blockHeight :: Double blockWidth = 64 blockHeight = 32 + blockSeparation :: Double blockSeparation = 10 + maxBlockLife :: Int maxBlockLife = 3 + minBlockLife :: Int minBlockLife = 1 From 085c8c0ab573592dfe2d091acf57763de43a973c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:30:07 +0000 Subject: [PATCH 125/201] Remove duplicate empty lines (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Display.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Display.hs b/src/Display.hs index a0092ac..0811853 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -286,7 +286,6 @@ loadResources = runMaybeT $ do liftIO $ ResourceMgr <$> newIORef (ResourceManager GameStarted res) - loadNewResources :: ResourceMgr -> GameState -> IO Resources loadNewResources mgr state = do manager <- readIORef (unResMgr mgr) From 9293a2349d1025f4d99a0f860e3f6bd153411855 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:31:08 +0000 Subject: [PATCH 126/201] Remove duplicate empty lines (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Game.hs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 7509baf..80379dc 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -245,7 +245,6 @@ composeGameState' lives level pts = proc (oos,dead,points) -> do returnA -< (general, lastGeneral) - -- ** Game with partial state information -- | Given an initial list of objects, it runs the game, presenting the output @@ -331,8 +330,6 @@ gamePlay' objs = loopPre ([],[],0) $ hasBall = any ((=="ball").fst) countBlocks = length . filter (isPrefixOf "block" . fst) - - -- * Game objects -- -- | Objects initially present: the walls, the ball, the paddle and the blocks. @@ -348,7 +345,6 @@ initialObjects level = listToIL $ ++ map (\p -> objBlock p (blockWidth, blockHeight)) (blockCfgs $ levels!!level) - -- *** Ball -- | Ball From feccd45925c4619f9d49a3a310bf6b91655ed384 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:31:10 +0000 Subject: [PATCH 127/201] Remove duplicate empty lines (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Input.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Input.hs b/src/Input.hs index e1b862a..689afbd 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -240,7 +240,6 @@ handleEvent c e = c { controllerQuit = True } _ -> c - -- Kinect #ifdef kinect From 4ac8d281499e88b200e25b534302c330f49717a1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:31:17 +0000 Subject: [PATCH 128/201] Remove duplicate empty lines (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/Levels.hs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index b83e0dd..0ad1fd0 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -167,8 +167,6 @@ blockDescS 0 = map (first adjustPos) allBlocks blockRows :: Num a => a blockRows = 4 - - -- Level 1 -- %%%%%%%% -- % XXXX @@ -220,7 +218,6 @@ blockDescS 3 = map (first adjustPos) allBlocks blockRows :: Num a => a blockRows = 4 - -- Level 4 -- %%%%%%%% -- % XXXXXXXX @@ -276,7 +273,6 @@ blockDescS 6 = map (first adjustPos) allBlocks blockRows :: Num a => a blockRows = 5 - -- Level 7 -- %%%%%%%% -- % XXXXXX @@ -345,7 +341,6 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks leftMargin = round' ((gameWidth - (blockWidth + blockSeparation) * 7)/2) where round' = fromIntegral . floor - -- Level 10 -- %%%%%%%% -- % X X X @@ -371,8 +366,6 @@ blockDescS 10 = map (first adjustPos) allBlocks midRow :: Integral a => a midRow = blockRows `div` 2 - - -- Level 11 -- %%%%%%%% -- % XX @@ -390,7 +383,6 @@ blockDescS 11 = map (first adjustPos) allBlocks - (2 * abs (y - midRow))] ] - blockRows :: Num a => a blockRows = 7 @@ -479,7 +471,6 @@ blockDescS 14 = map (first adjustPos) allBlocks blockRows :: Num a => a blockRows = 5 - -- Level 15 -- maxBlockLife == X -- minBlockLife == O @@ -512,7 +503,6 @@ blockDescS 15 = map (first adjustPos) allBlocks midRow :: Integral a => a midRow = blockRows `div` 2 - -- Level 16 -- maxBlockLife == X -- minBlockLife == O @@ -543,7 +533,6 @@ blockDescS 16 = map (first adjustPos) allBlocks blockRows - 2, blockRows - 1] , x /= midColumn - 1, x /= midColumn] - blockRows :: Num a => a blockRows = 8 @@ -588,8 +577,6 @@ blockDescS 17 = map (first adjustPos) allBlocks midColumn :: Integral a => a midColumn = blockColumns `div` 2 - - blockDescS _ = error "No more levels" -- Dynamic positioning/level size From 001ae94c00892a249eaabcf11a8f9ce90b1158c4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:31:18 +0000 Subject: [PATCH 129/201] Remove duplicate empty lines (KSG Haskell 1.3.0 - 4.5.1). Refs #103. A single blank line should appear between consecutive definitions. --- src/ObjectSF.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index b47f946..ec0f09b 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -56,7 +56,6 @@ data ObjectOutput = ObjectOutput , harakiri :: Event () -- ^ Whether the object has died (killed itself). } - -- | Handy function to create an object that is currently alive. livingObject :: Object -> ObjectOutput livingObject o = ObjectOutput o noEvent From 4626f8bea8a30e97a765203f2108b686f002517e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:32:32 +0000 Subject: [PATCH 130/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/Data/Extra/Ord.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Data/Extra/Ord.hs b/src/Data/Extra/Ord.hs index ec4f6b4..ebde740 100644 --- a/src/Data/Extra/Ord.hs +++ b/src/Data/Extra/Ord.hs @@ -8,4 +8,3 @@ module Data.Extra.Ord where inRange :: Ord a => (a,a) -> a -> a inRange (mN, mX) x = min mX (max mN x) - From fa905ecd1a6ab15df56bd10e9e298be3be13fd9a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:33:10 +0000 Subject: [PATCH 131/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/FRP/Extra/Yampa.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 6ae1193..906d787 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -41,4 +41,3 @@ boolToEvent :: Bool -> a -> Event a boolToEvent True = Event boolToEvent _ = \_ -> noEvent {-# INLINE boolToEvent #-} - From 90978506f10846a0822ff3c5d5ca9be33c14746c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:33:11 +0000 Subject: [PATCH 132/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/Graphics/UI/Extra/FPS.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Graphics/UI/Extra/FPS.hs b/src/Graphics/UI/Extra/FPS.hs index 3fc642d..3773a1e 100644 --- a/src/Graphics/UI/Extra/FPS.hs +++ b/src/Graphics/UI/Extra/FPS.hs @@ -43,4 +43,3 @@ stepFPSCounter (clock, fpsRef, every) = do ++ ", Total running time: " ++ show newTime writeIORef fpsRef (newTime, every) else do writeIORef fpsRef (lastTime, left') - From 19796a6e1779627b32788615b47c4740dee8c393 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:33:12 +0000 Subject: [PATCH 133/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/Input.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Input.hs b/src/Input.hs index 689afbd..3a1363a 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -343,4 +343,3 @@ adjust maxD old new | otherwise = old - maxD #endif - From 846598a84081d0b3ec3c8446c514406ea70411ff Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:33:13 +0000 Subject: [PATCH 134/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/Main.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Main.hs b/src/Main.hs index 2334c2a..a710fff 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -29,4 +29,3 @@ main = do ) (\_ (e, c) -> render res' e >> return (controllerQuit c)) (wholeGame &&& arr id) - From 80da8af72a5b3e6e83afae985209d29ce00b39a1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 16:33:13 +0000 Subject: [PATCH 135/201] Remove empty line at end of file (KSG Haskell 1.3.0 - 4.5.2). Refs #103. Do not leave any empty lines at the end of the file. --- src/ObjectSF.hs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index ec0f09b..7cbbdc7 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -69,4 +69,3 @@ extractObjects = arr (fmap outputObject) -- | A list of object outputs type ObjectOutputs = [ObjectOutput] - From 83915e849a320a12a3bd2bf2b3cbb4eb070ec778 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:55:15 +0000 Subject: [PATCH 136/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Data/Extra/Ord.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Extra/Ord.hs b/src/Data/Extra/Ord.hs index ebde740..30a8f0c 100644 --- a/src/Data/Extra/Ord.hs +++ b/src/Data/Extra/Ord.hs @@ -6,5 +6,5 @@ -- Auxiliary functions related to the 'Ord' typeclass. module Data.Extra.Ord where -inRange :: Ord a => (a,a) -> a -> a +inRange :: Ord a => (a, a) -> a -> a inRange (mN, mX) x = min mX (max mN x) From e62232ece9312d7871d4710674852a9de19d7412 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:17 +0000 Subject: [PATCH 137/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Display.hs | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index 0811853..fb74a5b 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -173,29 +173,29 @@ paintGeneralHUD screen resources over = void $ do paintObject :: Resources -> Surface -> Object -> IO () paintObject resources screen object = case objectKind object of - (Paddle (w,h)) -> void $ do let bI = imgSurface $ paddleImg resources - t <- mapRGB - (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ - Just (SDL.Rect x y (round w) (round h)) - (Block e (w,h)) -> void $ do let bI = imgSurface $ blockImage e - SDL.blitSurface bI Nothing screen $ - Just (SDL.Rect x y (round w) (round h)) - (Ball r) -> void $ do let x' = x - round r - y' = y - round r - sz = round (2*r) - -- b <- convertSurface - -- (imgSurface $ ballImg resources) - -- (format) - -- [] - let bI = imgSurface $ ballImg resources - t <- mapRGB - (surfaceGetPixelFormat bI) 0 255 0 - setColorKey bI [SrcColorKey, RLEAccel] t - SDL.blitSurface bI Nothing screen $ - Just (SDL.Rect x' y' sz sz) - _ -> return () + (Paddle (w, h)) -> void $ do let bI = imgSurface $ paddleImg resources + t <- mapRGB + (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x y (round w) (round h)) + (Block e (w, h)) -> void $ do let bI = imgSurface $ blockImage e + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x y (round w) (round h)) + (Ball r) -> void $ do let x' = x - round r + y' = y - round r + sz = round (2*r) + -- b <- convertSurface + -- (imgSurface $ ballImg resources) + -- (format) + -- [] + let bI = imgSurface $ ballImg resources + t <- mapRGB + (surfaceGetPixelFormat bI) 0 255 0 + setColorKey bI [SrcColorKey, RLEAccel] t + SDL.blitSurface bI Nothing screen $ + Just (SDL.Rect x' y' sz sz) + _ -> return () where format = surfaceGetPixelFormat screen p = objectPos object x = round (fst p) From 729e5e172148d2bb7e5967e4344a013fe00d21b2 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:20 +0000 Subject: [PATCH 138/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/FRP/Extra/Yampa.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 906d787..fc8ce33 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -14,18 +14,18 @@ import FRP.Yampa -- holdWhen behaves normally, outputting only the b, when the second value -- is false, and it holds the last known value when the value is True. -holdWhen :: b -> SF a (b,Bool) -> SF a b +holdWhen :: b -> SF a (b, Bool) -> SF a b holdWhen bInit sf = sf >>> holdOutput >>> hold bInit - where holdOutput = arr (\(b,discard) -> if discard then noEvent else Event b) + where holdOutput = arr (\(b, discard) -> if discard then noEvent else Event b) -- Given an occasional producer of functions and a source of info, apply the -- functions when they exist mergeApply :: SF a b -> SF a (Event (b -> b)) -> SF a b mergeApply sf1 sf2 = - (sf1 &&& sf2) >>> (arr (\(b,ef) -> event b ($ b) ef)) + (sf1 &&& sf2) >>> (arr (\(b, ef) -> event b ($ b) ef)) mergeApply' :: SF a (b, Event (b -> b)) -> SF a b -mergeApply' sf1 = sf1 >>> (arr (\(b,ef) -> event b ($ b) ef)) +mergeApply' sf1 = sf1 >>> (arr (\(b, ef) -> event b ($ b) ef)) rRestart :: SF a (b, Event c) -> SF a b rRestart sf = r From 92df89f1eff3b94c4a05bf561a98f9f52545be3d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:23 +0000 Subject: [PATCH 139/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/GameCollisions.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index 19d838b..bbc1c99 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -62,7 +62,7 @@ detectCollisions''' m o | otherwise = maybeToList (detectCollision (snd m) (snd o)) -- updateObjPos :: SF (ILKey, Object) (ILKey, Object) --- updateObjPos = proc (i,o) -> do +-- updateObjPos = proc (i, o) -> do -- -- Since we are saving the position to avoid having to keep the last known -- -- position in memory every time and integrate over a range every time -- -- (would that really happen???) we use an integral over an interval. @@ -70,13 +70,13 @@ detectCollisions''' m o -- -- expected to work. Does it work well for non-linear equations? -- -- -- -- Integral only for dt interval --- actualVel <- iterFrom (\_ (v1,v2) dt _ -> (v1 * dt, v2 * dt)) (0,0) +-- actualVel <- iterFrom (\_ (v1, v2) dt _ -> (v1 * dt, v2 * dt)) (0, 0) -- -< objectVel o -- -- -- Update position -- let newPos = objectPos o ^+^ actualVel -- o' = o { objectPos = newPos } --- returnA -< (i,o') +-- returnA -< (i, o') -- killBall :: ObjectOutput -> ObjectOutput -- killBall oo = oo { outputObject = o' } @@ -116,7 +116,7 @@ changedVelocity name cs = (_, v') : _ -> Just v' -- IP: It should be something like the following, but that doesn't work: - -- vs -> Just (foldl (^+^) (0,0) (map snd vs)) + -- vs -> Just (foldl (^+^) (0, 0) (map snd vs)) -- | True if the velocity of the object has been changed by any collision. inCollision :: ObjectName -> Collisions -> Bool From 1c1b6f4358d27f355e0202f552c5b05b9bb76864 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:31 +0000 Subject: [PATCH 140/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Game.hs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 80379dc..3ea7f84 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -234,7 +234,7 @@ composeGameState lives level pts = futureDSwitch composeGameState' :: Int -> Int -> Int -> SF (ObjectOutputs, Event (), Int) (GameState, Event GameState) -composeGameState' lives level pts = proc (oos,dead,points) -> do +composeGameState' lives level pts = proc (oos, dead, points) -> do -- Compose game state objects <- extractObjects -< oos let general = GameState objects @@ -263,7 +263,7 @@ composeGameState' lives level pts = proc (oos,dead,points) -> do -- - The last known points (added to the new ones in every loop iteration). -- gamePlay' :: ObjectSFs -> SF Controller (ObjectOutputs, Event (), Int) -gamePlay' objs = loopPre ([],[],0) $ +gamePlay' objs = loopPre ([], [], 0) $ -- Process physical movement and detect new collisions ( ( adaptInput >>> processMovement @@ -273,24 +273,24 @@ gamePlay' objs = loopPre ([],[],0) $ ) -- Adds the old point count to the newly-made points - >>> (arr fst &&& arr (\((_,cs),o) -> o + countPoints cs)) + >>> (arr fst &&& arr (\((_, cs), o) -> o + countPoints cs)) -- Re-arrange output, selecting -- (objects+dead+points, objects+collisions+points) - >>> (composeOutput &&& arr (\((x,y),z) -> (x,y,z))) + >>> (composeOutput &&& arr (\((x, y), z) -> (x, y, z))) where -- Detect collisions between the ball and the bottom -- which are the only ones that matter outside gamePlay' - composeOutput = proc ((x,y),z) -> do + composeOutput = proc ((x, y), z) -> do y' <- collisionWithBottom -< y - returnA -< (x,y',z) + returnA -< (x, y', z) -- Just reorder the input adaptInput :: SF (Controller, (ObjectOutputs, Collisions, Int)) ObjectInput adaptInput = - arr (\(gi,(os,cs,pts)) -> ObjectInput gi cs (map outputObject os)) + arr (\(gi, (os, cs, pts)) -> ObjectInput gi cs (map outputObject os)) -- Parallely apply all object functions processMovement :: SF ObjectInput (IL ObjectOutput) @@ -305,7 +305,7 @@ gamePlay' objs = loopPre ([],[],0) $ -- (with new state, aka. sfs). suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) - suicidalSect (_,oos) = + suicidalSect (_, oos) = -- Turn every event carrying a function that transforms the object -- signal function list into one function that performs all the efects -- in sequence @@ -315,7 +315,7 @@ gamePlay' objs = loopPre ([],[],0) $ -- removes it from the list where es :: [Event (IL ObjectSF -> IL ObjectSF)] es = [ harakiri oo `tag` deleteIL k - | (k,oo) <- assocsIL oos ] + | (k, oo) <- assocsIL oos ] -- From the actual objects, detect which ones collide detectObjectCollisions :: SF (IL ObjectOutput) Collisions @@ -534,10 +534,10 @@ objPaddle = proc (ObjectInput ci cs os) -> do returnA -< livingObject $ Object{ objectName = name - , objectKind = Paddle (paddleWidth,paddleHeight) + , objectKind = Paddle (paddleWidth, paddleHeight) , objectPos = p - , objectVel = (0,0) - , objectAcc = (0,0) + , objectVel = (0, 0) + , objectAcc = (0, 0) , objectDead = False , objectHit = isHit , canCauseCollisions = True @@ -565,10 +565,10 @@ yPosPaddle = gameHeight - paddleMargin -- same position. This is ok in this case because they are static, but would not -- work if they could move and be created dynamically. objBlock :: (Pos2D, Int) -> Size2D -> ObjectSF -objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do +objBlock ((x, y), initlives) (w, h) = proc (ObjectInput ci cs os) -> do -- Detect collisions - let name = "blockat" ++ show (x,y) + let name = "blockat" ++ show (x, y) isHit = inCollision name cs hit <- edge -< isHit @@ -591,9 +591,9 @@ objBlock ((x,y), initlives) (w,h) = proc (ObjectInput ci cs os) -> do returnA -< ObjectOutput Object{ objectName = name , objectKind = Block lives (w, h) - , objectPos = (x,y) - , objectVel = (0,0) - , objectAcc = (0,0) + , objectPos = (x, y) + , objectVel = (0, 0) + , objectAcc = (0, 0) , objectDead = isDead , objectHit = isHit , canCauseCollisions = False @@ -638,8 +638,8 @@ objWall name side pos = proc (ObjectInput ci cs os) -> do Object { objectName = name , objectKind = Side side , objectPos = pos - , objectVel = (0,0) - , objectAcc = (0,0) + , objectVel = (0, 0) + , objectAcc = (0, 0) , objectDead = False , objectHit = isHit , canCauseCollisions = False From 95bd6ab9664991081bf498dabbb8599185248fdd Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:38 +0000 Subject: [PATCH 141/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Input.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 3a1363a..19c3285 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -50,7 +50,7 @@ import System.CWiid -- External imports (Kinect) #ifdef kinect import Control.Concurrent -import Data.Vector.Storable (Vector,(!)) +import Data.Vector.Storable (Vector, (!)) import qualified Data.Vector.Storable as V import Data.Word import Freenect @@ -107,7 +107,7 @@ initializeInputDevices = do nr <- newIORef defaultInfo return $ ControllerRef (nr, dev') - where defaultInfo = Controller (0,0) False False False + where defaultInfo = Controller (0, 0) False False False -- | Sense from the controller, providing its current state. This should return -- a new Controller state if available, or the last one there was. @@ -182,7 +182,7 @@ senseWiimote wmdev controller = do -- Direction (old system based on buttons) -- let isLeft = cwiidIsBtnPushed flags cwiidBtnLeft -- isRight = cwiidIsBtnPushed flags cwiidBtnRight - -- (x,y) = controllerPos controller + -- (x, y) = controllerPos controller -- x' | isLeft = x - wiiXDiff -- | isRight = x + wiiXDiff -- | otherwise = x @@ -289,11 +289,11 @@ getDepthThread screenSize lastPos = forkIO $ do index = 0 :: Integer updatePos :: IORef (Maybe (Double, Double)) -> (Double, Double) -> IO () -updatePos lastPosRef newPos@(nx,ny) = do +updatePos lastPosRef newPos@(nx, ny) = do lastPosM <- readIORef lastPosRef let (mx, my) = case lastPosM of - Nothing -> newPos - (Just (lx,ly)) -> (adjust 50 lx nx, adjust 50 ly ny) + Nothing -> newPos + (Just (lx, ly)) -> (adjust 50 lx nx, adjust 50 ly ny) writeIORef lastPosRef (Just (mx, my)) mx `seq` my `seq` return () @@ -302,7 +302,7 @@ calculateMousePos :: (Double, Double) -> Maybe (Double, Double) calculateMousePos (width, height) payload = fmap g (findFirst payload) - where g (px,py) = (mousex, mousey) + where g (px, py) = (mousex, mousey) where pointerx = fromIntegral (640 - px) pointery = fromIntegral py @@ -333,7 +333,7 @@ processPayload ps = [(pval, tx, ty) | i <- [0..640*480-1] avg :: [(Float, Int, Int)] -> (Int, Int) avg ls = (sumx `div` l, sumy `div` l) where l = length ls - (sumx, sumy) = foldr (\(_,x,y) (rx,ry) -> (x+rx,y+ry)) (0,0) ls + (sumx, sumy) = foldr (\(_, x, y) (rx, ry) -> (x+rx, y+ry)) (0, 0) ls -- Update a value, with a max cap adjust :: (Num a, Ord a) => a -> a -> a -> a From 02b1cc92c12d3ea1406f7eee7faf852df80183f1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:51 +0000 Subject: [PATCH 142/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Levels.hs | 248 +++++++++++++++++++++++++------------------------- 1 file changed, 124 insertions(+), 124 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 0ad1fd0..0cd36bc 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -148,7 +148,7 @@ levels = [ -- Level 0 } ] --- | Level block specification (positions,lives of block) +-- | Level block specification (positions, lives of block) -- Level 0 -- %%%%%%%% @@ -159,9 +159,9 @@ levels = [ -- Level 0 blockDescS :: Int -> [(Pos2D, Int)] blockDescS 0 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] + where allBlocks :: (Enum a, Num a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] ] blockRows :: Num a => a @@ -178,10 +178,10 @@ blockDescS 0 = map (first adjustPos) allBlocks -- blockDescS 1 = map (first adjustPos) allBlocks where - allBlocks :: (Enum a, Num a, Eq a, Ord a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x + y > 2) && (x + y < 10) + allBlocks :: (Enum a, Num a, Eq a, Ord a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x + y > 2) && (x + y < 10) ] blockRows :: Num a => a @@ -190,10 +190,10 @@ blockDescS 1 = map (first adjustPos) allBlocks -- Level 2 blockDescS 2 = map (first adjustPos) allBlocks where - allBlocks :: (Enum a, Num a, Eq a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= y && (blockColumns - 1 - x) /= y + allBlocks :: (Enum a, Num a, Eq a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= y && (blockColumns - 1 - x) /= y ] blockRows :: Num a => a @@ -208,11 +208,11 @@ blockDescS 2 = map (first adjustPos) allBlocks -- % X X X X blockDescS 3 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , ((even x) && (odd y) || - (odd x) && (even y)) + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , ((even x) && (odd y) || + (odd x) && (even y)) ] blockRows :: Num a => a @@ -229,13 +229,13 @@ blockDescS 3 = map (first adjustPos) allBlocks -- % XXXXXXXX blockDescS 4 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0,blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [2], odd x] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [4], even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1]] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [2], odd x] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [4], even x] blockRows :: Num a => a blockRows = 7 @@ -248,12 +248,12 @@ blockDescS 4 = map (first adjustPos) allBlocks -- % XXXXXXX blockDescS 5 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] allBlocks = nub $ - [((3,0), maxBlockLife),((blockColumns - 4,1), maxBlockLife)] - ++ [((2,1), maxBlockLife),((blockColumns - 3,1), maxBlockLife)] - ++ [((1,2), maxBlockLife),((blockColumns - 2,2), maxBlockLife)] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] + [((3, 0), maxBlockLife), ((blockColumns - 4, 1), maxBlockLife)] + ++ [((2, 1), maxBlockLife), ((blockColumns - 3, 1), maxBlockLife)] + ++ [((1, 2), maxBlockLife), ((blockColumns - 2, 2), maxBlockLife)] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] -- Level 6 -- %%%%%%%% @@ -264,11 +264,11 @@ blockDescS 5 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 6 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1..blockRows - 2]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1]] + ++ [((x, y), maxBlockLife) | x <- [0, blockColumns - 1] + , y <- [1..blockRows - 2]] blockRows :: Num a => a blockRows = 5 @@ -283,13 +283,13 @@ blockDescS 6 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 7 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1, blockRows - 2]] - ++ [((x,y), maxBlockLife) | x <- [3,4] - , y <- [2..4]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1]] + ++ [((x, y), maxBlockLife) | x <- [0, blockColumns - 1] + , y <- [1, blockRows - 2]] + ++ [((x, y), maxBlockLife) | x <- [3, 4] + , y <- [2..4]] blockRows :: Num a => a blockRows = 7 @@ -308,10 +308,10 @@ blockDescS 7 = map (first adjustPos) allBlocks -- % XX XXXXX blockDescS 8 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= 2, y /= 2 + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= 2, y /= 2 ] blockRows :: Num a => a @@ -328,11 +328,11 @@ blockDescS 8 = map (first adjustPos) allBlocks -- % X blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [3], y <- [0..6]] - ++ [((x,y), maxBlockLife) | x <- [0..6], y <- [3]] - ++ [((x,y), maxBlockLife) | x <- [2,4], y <- [1,5]] - ++ [((x,y), maxBlockLife) | x <- [1,5], y <- [2,4]] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [3], y <- [0..6]] + ++ [((x, y), maxBlockLife) | x <- [0..6], y <- [3]] + ++ [((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5]] + ++ [((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4]] adjustHPos :: Double -> Double adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) @@ -354,11 +354,11 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks -- % X X X blockDescS 10 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1], odd x] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1], odd x] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [midRow], even x] blockRows :: Num a => a blockRows = 9 @@ -377,10 +377,10 @@ blockDescS 10 = map (first adjustPos) allBlocks -- % XX blockDescS 11 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | y <- [0..blockRows-1] - , x <- [0..(blockColumns-1) - - (2 * abs (y - midRow))] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | y <- [0..blockRows-1] + , x <- [0..(blockColumns-1) + - (2 * abs (y - midRow))] ] blockRows :: Num a => a @@ -400,15 +400,15 @@ blockDescS 11 = map (first adjustPos) allBlocks blockDescS 12 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0]] - ++ [((x,y), maxBlockLife) | x <- [2, blockColumns - 3] - , y <- [1, 2]] - ++ [ ((1,4), maxBlockLife) - , ((blockColumns - 2,4), maxBlockLife) - , ((0,5), maxBlockLife) - , ((blockColumns - 1,5), maxBlockLife) + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0]] + ++ [((x, y), maxBlockLife) | x <- [2, blockColumns - 3] + , y <- [1, 2]] + ++ [ ((1, 4), maxBlockLife) + , ((blockColumns - 2, 4), maxBlockLife) + , ((0, 5), maxBlockLife) + , ((blockColumns - 1, 5), maxBlockLife) ] blockRows :: Num a => a @@ -424,8 +424,8 @@ blockDescS 12 = map (first adjustPos) allBlocks -- % OXOXOXOX blockDescS 13 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), blockLife) | x <- [0..blockColumns - 1] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), blockLife) | x <- [0..blockColumns - 1] , y <- [0..blockRows - 1] , let blockLife = if even (x + y) @@ -448,25 +448,25 @@ blockDescS 13 = map (first adjustPos) allBlocks -- % YYYYYYYY blockDescS 14 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x == 0) - || (y == 0) - || (x == blockColumns - 1) - || (y == blockRows - 1)] - ++ [((x,y), maxBlockLife - 1) | x <- [1..blockColumns - 2] - , y <- [1..blockRows - 2] - , (x == 1) - || (y == 1) - || (x == blockColumns - 2) - || (y == blockRows - 2)] - ++ [((x,y), maxBlockLife) | x <- [2..blockColumns - 3] - , y <- [2..blockRows - 3] - , (x == 2) - || (y == 2) - || (x == blockColumns - 3) - || (y == blockRows - 3)] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x == 0) + || (y == 0) + || (x == blockColumns - 1) + || (y == blockRows - 1)] + ++ [((x, y), maxBlockLife - 1) | x <- [1..blockColumns - 2] + , y <- [1..blockRows - 2] + , (x == 1) + || (y == 1) + || (x == blockColumns - 2) + || (y == blockRows - 2)] + ++ [((x, y), maxBlockLife) | x <- [2..blockColumns - 3] + , y <- [2..blockRows - 3] + , (x == 2) + || (y == 2) + || (x == blockColumns - 3) + || (y == blockRows - 3)] blockRows :: Num a => a blockRows = 5 @@ -487,15 +487,15 @@ blockDescS 14 = map (first adjustPos) allBlocks -- % T T T blockDescS 15 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] - allBlocks = [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..midRow], odd x] - ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] - ++ [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midRow - + 1..blockColumns - 1] - , even x] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0..midRow], odd x] + ++ [((x, y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [midRow], even x] + ++ [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [midRow + + 1..blockColumns - 1] + , even x] blockRows :: Num a => a blockRows = 9 @@ -519,19 +519,19 @@ blockDescS 15 = map (first adjustPos) allBlocks blockDescS 16 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] allBlocks = - [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midColumn - 1, midColumn] - , (even x && y == midColumn) - || (odd x && y == midColumn -1)] - ++ [((x,y), minBlockLife) | x <- [midColumn - 1, midColumn] - , y <- [0, 1, - blockRows - 2, blockRows - 1]] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, 1, - blockRows - 2, blockRows - 1] - , x /= midColumn - 1, x /= midColumn] + [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [midColumn - 1, midColumn] + , (even x && y == midColumn) + || (odd x && y == midColumn -1)] + ++ [((x, y), minBlockLife) | x <- [midColumn - 1, midColumn] + , y <- [0, 1, + blockRows - 2, blockRows - 1]] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, 1, + blockRows - 2, blockRows - 1] + , x /= midColumn - 1, x /= midColumn] blockRows :: Num a => a blockRows = 8 @@ -558,18 +558,18 @@ blockDescS 16 = map (first adjustPos) allBlocks -- % XXX XXXX blockDescS 17 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a,a), Int)] + where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] allBlocks = - [((x,y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [3, 4] - , odd x] - ++ [((x,y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [1, 2, - blockRows - 4, blockRows - 3] - , even x ] - ++ [((x,y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - , y == 0 || x /= midColumn] + [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] + , y <- [3, 4] + , odd x] + ++ [((x, y), minBlockLife) | x <- [0..blockColumns - 1] + , y <- [1, 2, + blockRows - 4, blockRows - 3] + , even x ] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + , y == 0 || x /= midColumn] blockRows :: Num a => a blockRows = 9 @@ -581,7 +581,7 @@ blockDescS _ = error "No more levels" -- Dynamic positioning/level size -adjustPos :: Integral a => (a,a) -> (Double, Double) +adjustPos :: Integral a => (a, a) -> (Double, Double) adjustPos = ((adjustHPos *** adjustVPos) . fI2) adjustVPos :: Double -> Double @@ -608,5 +608,5 @@ leftMargin = 25 -- * Auxiliary functions -fI2 :: Integral a => (a,a) -> (Double, Double) -fI2 (x,y) = (fromIntegral x, fromIntegral y) +fI2 :: Integral a => (a, a) -> (Double, Double) +fI2 (x, y) = (fromIntegral x, fromIntegral y) From 28354edb6ae1be5bd7130a1b30cfdcd20753cf54 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:55 +0000 Subject: [PATCH 143/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Objects.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index 512075e..d4b5a61 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -50,7 +50,7 @@ data ObjectKind = Ball Double -- radius? | Paddle Size2D | Block Energy Size2D | Side Side - deriving (Show,Eq) + deriving (Show, Eq) type Energy = Int @@ -69,7 +69,7 @@ isPaddle o = case objectKind o of objShape :: Object -> Shape objShape obj = case objectKind obj of - (Ball r) -> Rectangle (p ^-^ (r,r)) (2*r, 2*r) + (Ball r) -> Rectangle (p ^-^ (r, r)) (2*r, 2*r) (Paddle s) -> Rectangle p s (Block _ s) -> Rectangle p s (Side s) -> sideToShape p s @@ -118,7 +118,7 @@ collisionResponseObj o1 o2 = objectReacts o = collisionEnergy o > 0 || displacedOnCollision o - objectToCollision (o,s,o') = + objectToCollision (o, s, o') = ( objectName o , correctVel (objectVel o ^+^ (velTrans *^ objectVel o')) @@ -126,7 +126,7 @@ collisionResponseObj o1 o2 = s ) - correctVel (vx,vy) e TopSide = (vx, ensurePos (vy * (-e))) - correctVel (vx,vy) e BottomSide = (vx, ensureNeg (vy * (-e))) - correctVel (vx,vy) e LeftSide = (ensureNeg (vx * (-e)),vy) - correctVel (vx,vy) e RightSide = (ensurePos (vx * (-e)),vy) + correctVel (vx, vy) e TopSide = (vx, ensurePos (vy * (-e))) + correctVel (vx, vy) e BottomSide = (vx, ensureNeg (vy * (-e))) + correctVel (vx, vy) e LeftSide = (ensureNeg (vx * (-e)), vy) + correctVel (vx, vy) e RightSide = (ensurePos (vx * (-e)), vy) From b718cca44fbf689c42ccd8ec5eba9f8a520541a0 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:57 +0000 Subject: [PATCH 144/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Physics/TwoDimensions/Collisions.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index 7cdc333..b2c9b93 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -19,7 +19,7 @@ import Physics.TwoDimensions.Physics -- | Collision side of a rectangle data Side = TopSide | BottomSide | LeftSide | RightSide - deriving (Eq,Show) + deriving (Eq, Show) -- | Opposite side during a collision. -- @@ -39,7 +39,7 @@ shapeCollisionSide (Rectangle p1 s1) (Rectangle p2 s2) | wy > hx = LeftSide | wy > -hx = RightSide | otherwise = BottomSide - where (dx,dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) -- p1 ^-^ p2 - (w,h) = 0.5 *^ (s1 ^+^ s2) - wy = w * dy - hx = h * dx + where (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) -- p1 ^-^ p2 + (w, h) = 0.5 *^ (s1 ^+^ s2) + wy = w * dy + hx = h * dx From c91af6e38590c0ee68db39e6f406c00b8001e6a6 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 21:56:58 +0000 Subject: [PATCH 145/201] Add space after comma (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear after the comma (,) in lists and tuples. --- src/Physics/TwoDimensions/Physics.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index d3f0eae..1dbdca9 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -26,5 +26,5 @@ data Shape = Rectangle Pos2D Size2D -- A corner and the whole size overlapShape :: Shape -> Shape -> Bool overlapShape (Rectangle p1 s1) (Rectangle p2 s2) = abs dx <= w && abs dy <= h - where (dx,dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) - (w,h) = 0.5 *^ (s1 ^+^ s2) + where (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) + (w, h) = 0.5 *^ (s1 ^+^ s2) From 1075350aa10b1c3b1caa0c10c734591d80ab3438 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:08:45 +0000 Subject: [PATCH 146/201] Add space after binary operator (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear on both sides of any binary or ternary operator. --- src/Display.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Display.hs b/src/Display.hs index fb74a5b..cd78964 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -184,7 +184,7 @@ paintObject resources screen object = Just (SDL.Rect x y (round w) (round h)) (Ball r) -> void $ do let x' = x - round r y' = y - round r - sz = round (2*r) + sz = round (2 * r) -- b <- convertSurface -- (imgSurface $ ballImg resources) -- (format) From 2b0ec810f194e2190fbadd08fe3648cba2f59333 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:09:29 +0000 Subject: [PATCH 147/201] Add space after binary operator (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear on both sides of any binary or ternary operator. --- src/Game.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 3ea7f84..98aeda3 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -226,7 +226,7 @@ composeGameState :: Int -> Int -> Int -> SF (ObjectOutputs, Event (), Int) GameState composeGameState lives level pts = futureDSwitch (composeGameState' lives level pts) - (\_ -> composeGameState (lives-1) level pts) + (\_ -> composeGameState (lives - 1) level pts) -- | Based on the internal gameplay info, compose the main game state and -- detect when a live is lost. When that happens, keep the last known game @@ -238,7 +238,7 @@ composeGameState' lives level pts = proc (oos, dead, points) -> do -- Compose game state objects <- extractObjects -< oos let general = GameState objects - (GameInfo GamePlaying lives level (pts+points)) + (GameInfo GamePlaying lives level (pts + points)) -- Detect death let lastGeneral = dead `tag` general @@ -276,7 +276,7 @@ gamePlay' objs = loopPre ([], [], 0) $ >>> (arr fst &&& arr (\((_, cs), o) -> o + countPoints cs)) -- Re-arrange output, selecting - -- (objects+dead+points, objects+collisions+points) + -- (objects + dead + points, objects + collisions + points) >>> (composeOutput &&& arr (\((x, y), z) -> (x, y, z))) where @@ -343,7 +343,7 @@ initialObjects level = listToIL $ , objBall ] ++ map (\p -> objBlock p (blockWidth, blockHeight)) - (blockCfgs $ levels!!level) + (blockCfgs $ levels !! level) -- *** Ball @@ -388,7 +388,7 @@ followPaddle = arr $ \oi -> -- should never happen in practice. let mbPaddlePos = objectPos <$> find isPaddle (knownObjects oi) ballPos = maybe (outOfScreen, outOfScreen) - ((paddleWidth/2, - ballHeight) ^+^) + ((paddleWidth / 2, - ballHeight) ^+^) mbPaddlePos in ObjectOutput (inertBallAt ballPos) noEvent where outOfScreen = -10 @@ -551,7 +551,7 @@ refPosPaddle :: Controller -> Pos2D refPosPaddle c = (x', yPosPaddle) where (x, _) = controllerPos c - x' = inRange (0, gameWidth - paddleWidth) (x - (paddleWidth/2)) + x' = inRange (0, gameWidth - paddleWidth) (x - (paddleWidth / 2)) -- | The paddle's vertical position, at a reasonable distance from the bottom. yPosPaddle :: Double From 3399680f689f9a50dfdc42f6b6f0d127362c43ba Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:09:32 +0000 Subject: [PATCH 148/201] Add space after binary operator (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear on both sides of any binary or ternary operator. --- src/Input.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 19c3285..9a71488 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -164,8 +164,8 @@ senseWiimote wmdev controller = do -- Obtain positions of leds 1 and 2 (with a normal wii bar, those -- will be the ones we use). - let led1 = irs!!0 - led2 = irs!!1 + let led1 = irs !! 0 + led2 = irs !! 1 -- Calculate mid point between sensor bar leds let posX = ((cwiidIRSrcPosX led1) + (cwiidIRSrcPosX led2)) `div` 2 @@ -314,16 +314,16 @@ calculateMousePos (width, height) payload = mat :: Vector Float mat = V.generate 2048 $ \i -> let v :: Float - v = ((fromIntegral i/2048.0)^3)*6.0 + v = ((fromIntegral i / 2048.0)^3) * 6.0 in v * 6.0 * 256.0 findFirst :: Vector Word16 -> Maybe (Int, Int) findFirst vs = fmap (\v -> (v `mod` 640, v `div` 640)) i - where i = V.findIndex (\x -> mat!(fromIntegral x) < 512) vs + where i = V.findIndex (\x -> mat ! (fromIntegral x) < 512) vs processPayload :: Vector Word16 -> [(Float, Int, Int)] -processPayload ps = [(pval, tx, ty) | i <- [0..640*480-1] - , let pval = mat!(fromIntegral (ps!i)) +processPayload ps = [(pval, tx, ty) | i <- [0 .. 640 * 480 - 1] + , let pval = mat ! (fromIntegral (ps ! i)) , pval < 300 , let ty = i `div` 640 tx = i `mod` 640 @@ -333,7 +333,7 @@ processPayload ps = [(pval, tx, ty) | i <- [0..640*480-1] avg :: [(Float, Int, Int)] -> (Int, Int) avg ls = (sumx `div` l, sumy `div` l) where l = length ls - (sumx, sumy) = foldr (\(_, x, y) (rx, ry) -> (x+rx, y+ry)) (0, 0) ls + (sumx, sumy) = foldr (\(_, x, y) (rx, ry) -> (x + rx, y + ry)) (0, 0) ls -- Update a value, with a max cap adjust :: (Num a, Ord a) => a -> a -> a -> a From d37fdc71bbed4c66c779abfc4ac46957ea90172b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:09:33 +0000 Subject: [PATCH 149/201] Add space after binary operator (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear on both sides of any binary or ternary operator. --- src/Levels.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 0cd36bc..585dbac 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -338,7 +338,8 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) leftMargin :: Num a => a - leftMargin = round' ((gameWidth - (blockWidth + blockSeparation) * 7)/2) + leftMargin = + round' ((gameWidth - (blockWidth + blockSeparation) * 7) / 2) where round' = fromIntegral . floor -- Level 10 @@ -378,8 +379,8 @@ blockDescS 10 = map (first adjustPos) allBlocks blockDescS 11 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | y <- [0..blockRows-1] - , x <- [0..(blockColumns-1) + allBlocks = [((x, y), maxBlockLife) | y <- [0 .. blockRows - 1] + , x <- [0 .. (blockColumns - 1) - (2 * abs (y - midRow))] ] From 0a03506ed1278b5355dc5608afe6ca69c0f826ae Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:09:36 +0000 Subject: [PATCH 150/201] Add space after binary operator (KSG Haskell 1.3.0 - 4.5.3). Refs #103. Beyond where required by the language or other style rules, and apart from literals and comments, a single ASCII space should also appear on both sides of any binary or ternary operator. --- src/Objects.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index d4b5a61..c623d20 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -69,7 +69,7 @@ isPaddle o = case objectKind o of objShape :: Object -> Shape objShape obj = case objectKind obj of - (Ball r) -> Rectangle (p ^-^ (r, r)) (2*r, 2*r) + (Ball r) -> Rectangle (p ^-^ (r, r)) (2 * r, 2 * r) (Paddle s) -> Rectangle p s (Block _ s) -> Rectangle p s (Side s) -> sideToShape p s @@ -77,10 +77,10 @@ objShape obj = case objectKind obj of width' = gameWidth height' = gameHeight d = collisionErrorMargin - sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2*d, d) - sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2*d) - sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2*d) - sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2*d, d) + sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2 * d, d) + sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2 * d) + sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2 * d) + sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2 * d, d) -- * Collisions type Collisions = [Collision] From 22ad014ebaf0ce3aab64f3ae5f37adc55c98106e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:12:53 +0000 Subject: [PATCH 151/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/Audio.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Audio.hs b/src/Audio.hs index faa84f0..abedc9d 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -68,6 +68,6 @@ loadAudio fp = fmap (Audio fp) <$> SDL.Mixer.Samples.tryLoadWAV fp -- This function spawns a new OS thread. Remember to compile your program -- with the threaded RTS. playFile :: Audio -> Int -> IO () -playFile wav t = void $ forkOS $ do +playFile wav t = void $ forkOS $ do _v <- SDL.Mixer.Channels.playChannel (-1) (unAudio wav) 0 threadDelay (t * 1000) From 28c047cc4ef6c81eeb0f0f09952e9f81b5a04875 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:01 +0000 Subject: [PATCH 152/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/Constants.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Constants.hs b/src/Constants.hs index 8665fb2..3aef73f 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -76,11 +76,11 @@ velTrans = 0.2 -- Max speed maxVNorm :: Double maxVNorm = 300 - + -- Delays -- restartDelay :: Time -- restartDelay = 3 --- +-- -- wonDelay :: Time -- wonDelay = 3 From e8aba1c571b25f2f99cf0e769ec201563a331439 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:02 +0000 Subject: [PATCH 153/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/Data/Extra/List.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Data/Extra/List.hs b/src/Data/Extra/List.hs index 4b1b1e9..888d863 100644 --- a/src/Data/Extra/List.hs +++ b/src/Data/Extra/List.hs @@ -7,4 +7,4 @@ module Data.Extra.List where mapFilter :: (a -> b) -> (a -> Bool) -> [a] -> [b] -mapFilter f p = map f . filter p +mapFilter f p = map f . filter p From d3b682e92a4760fa5ec4b16fd0459f926c51f406 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:05 +0000 Subject: [PATCH 154/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/FRP/Extra/Yampa.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index fc8ce33..37bb355 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -13,7 +13,7 @@ import FRP.Yampa -- Auxiliary Yampa stuff -- holdWhen behaves normally, outputting only the b, when the second value --- is false, and it holds the last known value when the value is True. +-- is false, and it holds the last known value when the value is True. holdWhen :: b -> SF a (b, Bool) -> SF a b holdWhen bInit sf = sf >>> holdOutput >>> hold bInit where holdOutput = arr (\(b, discard) -> if discard then noEvent else Event b) From 7751895c8f3efd243f6a8f96a060b4d6d9d38db2 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:06 +0000 Subject: [PATCH 155/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/GameCollisions.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index bbc1c99..adea98b 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -72,13 +72,13 @@ detectCollisions''' m o -- -- Integral only for dt interval -- actualVel <- iterFrom (\_ (v1, v2) dt _ -> (v1 * dt, v2 * dt)) (0, 0) -- -< objectVel o --- +-- -- -- Update position -- let newPos = objectPos o ^+^ actualVel -- o' = o { objectPos = newPos } -- returnA -< (i, o') --- killBall :: ObjectOutput -> ObjectOutput +-- killBall :: ObjectOutput -> ObjectOutput -- killBall oo = oo { outputObject = o' } -- where o = outputObject oo -- o' = o { objectDead = True} @@ -110,7 +110,7 @@ detectCollisions''' m o -- collieded with to facilitate impl. of "inCollisionWith". -- changedVelocity :: ObjectName -> Collisions -> Maybe Vel2D -changedVelocity name cs = +changedVelocity name cs = case concatMap (filter ((== name) . fst) . collisionData) cs of [] -> Nothing (_, v') : _ -> Just v' From b54544b92eca4b55a66fd9ed53efcc59c05ebeb4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:09 +0000 Subject: [PATCH 156/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/Input.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 9a71488..4295425 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -22,7 +22,7 @@ -- updated version. -- -- Limitations: --- +-- -- - Device failures are not handled. -- -- - Falling back to the next available device when there's a problem. @@ -111,7 +111,7 @@ initializeInputDevices = do -- | Sense from the controller, providing its current state. This should return -- a new Controller state if available, or the last one there was. --- +-- -- It is assumed that the sensing function is always callable, and that it -- knows how to update the Controller info if necessary. senseInput :: ControllerRef -> IO Controller @@ -181,12 +181,12 @@ senseWiimote wmdev controller = do -- Direction (old system based on buttons) -- let isLeft = cwiidIsBtnPushed flags cwiidBtnLeft - -- isRight = cwiidIsBtnPushed flags cwiidBtnRight + -- isRight = cwiidIsBtnPushed flags cwiidBtnRight -- (x, y) = controllerPos controller -- x' | isLeft = x - wiiXDiff -- | isRight = x + wiiXDiff -- | otherwise = x - -- x'' = inRange (0, gameWidth) x' + -- x'' = inRange (0, gameWidth) x' -- pos' = (x'', y) -- wiiXDiff :: Float -- wiiXDiff = 6 From 9ff8bedc78c405e11b8f2c9d2dd0e98d8105d3bc Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:20 +0000 Subject: [PATCH 157/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/Levels.hs | 70 +++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 585dbac..cd3435a 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -170,7 +170,7 @@ blockDescS 0 = map (first adjustPos) allBlocks -- Level 1 -- %%%%%%%% -- % XXXX --- % XXXXX +-- % XXXXX -- % XXXXXX -- % XXXXXX -- % XXXXX @@ -183,7 +183,7 @@ blockDescS 1 = map (first adjustPos) allBlocks , y <- [0..blockRows - 1] , (x + y > 2) && (x + y < 10) ] - + blockRows :: Num a => a blockRows = 6 @@ -198,7 +198,7 @@ blockDescS 2 = map (first adjustPos) allBlocks blockRows :: Num a => a blockRows = 4 - + -- Level 3 -- %%%%%%%% @@ -277,8 +277,8 @@ blockDescS 6 = map (first adjustPos) allBlocks -- %%%%%%%% -- % XXXXXX -- % X X --- % XX --- % XX +-- % XX +-- % XX -- % X X -- % XXXXXX blockDescS 7 = map (first adjustPos) allBlocks @@ -298,7 +298,7 @@ blockDescS 7 = map (first adjustPos) allBlocks -- %%%%%%%% -- % XX XXXXX -- % XX XXXXX --- % +-- % -- % XX XXXXX -- % XX XXXXX -- % XX XXXXX @@ -333,7 +333,7 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks ++ [((x, y), maxBlockLife) | x <- [0..6], y <- [3]] ++ [((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5]] ++ [((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4]] - + adjustHPos :: Double -> Double adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) @@ -345,14 +345,14 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks -- Level 10 -- %%%%%%%% -- % X X X --- % X X X --- % X X X --- % X X X +-- % X X X +-- % X X X +-- % X X X -- % XXXXXXX --- % X X X --- % X X X -- % X X X --- % X X X +-- % X X X +-- % X X X +-- % X X X blockDescS 10 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] @@ -360,7 +360,7 @@ blockDescS 10 = map (first adjustPos) allBlocks , y <- [0..blockRows - 1], odd x] ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] , y <- [midRow], even x] - + blockRows :: Num a => a blockRows = 9 @@ -369,13 +369,13 @@ blockDescS 10 = map (first adjustPos) allBlocks -- Level 11 -- %%%%%%%% --- % XX --- % XXXX --- % XXXXXX +-- % XX +-- % XXXX +-- % XXXXXX -- % XXXXXXXX --- % XXXXXX --- % XXXX --- % XX +-- % XXXXXX +-- % XXXX +-- % XX blockDescS 11 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] @@ -383,7 +383,7 @@ blockDescS 11 = map (first adjustPos) allBlocks , x <- [0 .. (blockColumns - 1) - (2 * abs (y - midRow))] ] - + blockRows :: Num a => a blockRows = 7 @@ -433,7 +433,7 @@ blockDescS 13 = map (first adjustPos) allBlocks then maxBlockLife else maxBlockLife - 1 ] - + blockRows :: Num a => a blockRows = 4 @@ -468,7 +468,7 @@ blockDescS 14 = map (first adjustPos) allBlocks || (y == 2) || (x == blockColumns - 3) || (y == blockRows - 3)] - + blockRows :: Num a => a blockRows = 5 @@ -478,14 +478,14 @@ blockDescS 14 = map (first adjustPos) allBlocks -- blockLife == T -- %%%%%%%% -- % X X X --- % X X X --- % X X X --- % X X X +-- % X X X +-- % X X X +-- % X X X -- % OXOXOXO --- % T T T --- % T T T -- % T T T --- % T T T +-- % T T T +-- % T T T +-- % T T T blockDescS 15 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] @@ -497,7 +497,7 @@ blockDescS 15 = map (first adjustPos) allBlocks , y <- [midRow + 1..blockColumns - 1] , even x] - + blockRows :: Num a => a blockRows = 9 @@ -511,10 +511,10 @@ blockDescS 15 = map (first adjustPos) allBlocks -- %%%%%%%% -- % XXXOOXXX -- % XXXOOXXX --- % +-- % -- % T T T T -- % T T T T --- % +-- % -- % XXXOOXXX -- % XXXOOXXX @@ -555,7 +555,7 @@ blockDescS 16 = map (first adjustPos) allBlocks -- % T T T T -- % O O O O -- % O O O O --- % +-- % -- % XXX XXXX blockDescS 17 = map (first adjustPos) allBlocks @@ -565,7 +565,7 @@ blockDescS 17 = map (first adjustPos) allBlocks , y <- [3, 4] , odd x] ++ [((x, y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [1, 2, + , y <- [1, 2, blockRows - 4, blockRows - 3] , even x ] ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] @@ -610,4 +610,4 @@ leftMargin = 25 -- * Auxiliary functions fI2 :: Integral a => (a, a) -> (Double, Double) -fI2 (x, y) = (fromIntegral x, fromIntegral y) +fI2 (x, y) = (fromIntegral x, fromIntegral y) From d994b7daff9e48c8eb28029a13c3074c73ad4d88 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:14:22 +0000 Subject: [PATCH 158/201] Remove trailing spaces (KSG Haskell 1.3.0 - 4.5.4.2). Refs #103. Do not leave any spaces at the end of any line. --- src/ObjectSF.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index 7cbbdc7..b8b9947 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -54,7 +54,7 @@ data ObjectInput = ObjectInput data ObjectOutput = ObjectOutput { outputObject :: Object -- ^ The object's state (position, shape, etc.). , harakiri :: Event () -- ^ Whether the object has died (killed itself). - } + } -- | Handy function to create an object that is currently alive. livingObject :: Object -> ObjectOutput From 9e6c1a66273761bbaa3b30e5d2c557e4437999c9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:08 +0000 Subject: [PATCH 159/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Constants.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Constants.hs b/src/Constants.hs index 3aef73f..bed9aca 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -13,16 +13,16 @@ import FRP.Yampa import Physics.TwoDimensions.Dimensions width :: Double -width = 640 +width = 640 height :: Double height = 600 -gameTop :: Double -gameTop = 100 +gameTop :: Double +gameTop = 100 -gameLeft :: Double -gameLeft = 0 +gameLeft :: Double +gameLeft = 0 gameWidth :: Double gameWidth = width @@ -41,15 +41,15 @@ paddleMargin :: Double paddleMargin = 50 ballWidth, ballHeight :: Double -ballWidth = 10 -ballHeight = 10 +ballWidth = 10 +ballHeight = 10 ballMargin :: Double -ballMargin = 30 +ballMargin = 30 blockWidth, blockHeight :: Double -blockWidth = 64 -blockHeight = 32 +blockWidth = 64 +blockHeight = 32 blockSeparation :: Double blockSeparation = 10 From 848841d4ff43511d8fb490d637ffdeddf89fafd0 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:38:23 +0000 Subject: [PATCH 160/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Display.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index cd78964..d6d5b0e 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -226,9 +226,9 @@ data Resources = Resources , bgMusic :: Maybe Music } -data Image = Image { imgName :: String, imgSurface :: Surface } +data Image = Image { imgName :: String, imgSurface :: Surface } -data Font = Font { fontName :: String, unFont :: TTF.Font } +data Font = Font { fontName :: String, unFont :: TTF.Font } -- | Ad-hoc resource loading -- @@ -242,7 +242,7 @@ loadResources = runMaybeT $ do gameFont <- liftIO $ getDataFileName "data/lacuna.ttf" -- Load the fonts we need - font <- liftIO $ TTF.tryOpenFont gameFont 32 -- What does the 32 do? + font <- liftIO $ TTF.tryOpenFont gameFont 32 -- What does the 32 do? let myFont = fmap (Font gameFont) font blockHit <- From 2a966603846e1b7ead2afe22d28b0639f761c4a5 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:42 +0000 Subject: [PATCH 161/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Game.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 98aeda3..5ca8efc 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -614,16 +614,16 @@ objBlock ((x, y), initlives) (w, h) = proc (ObjectInput ci cs os) -> do -- (for instance, if a really major Garbage Collection kicks in. One potential -- optimisation is to trigger these with every SF iteration or every rendering, -- to decrease the workload and thus the likelyhood of BTP effects. -objSideRight :: ObjectSF -objSideRight = objWall "rightWall" RightSide (gameWidth, 0) +objSideRight :: ObjectSF +objSideRight = objWall "rightWall" RightSide (gameWidth, 0) -- | See 'objSideRight'. -objSideLeft :: ObjectSF -objSideLeft = objWall "leftWall" LeftSide (0, 0) +objSideLeft :: ObjectSF +objSideLeft = objWall "leftWall" LeftSide (0, 0) -- | See 'objSideRight'. -objSideTop :: ObjectSF -objSideTop = objWall "topWall" TopSide (0, 0) +objSideTop :: ObjectSF +objSideTop = objWall "topWall" TopSide (0, 0) -- | See 'objSideRight'. objSideBottom :: ObjectSF From ebaefc16409dced75f2a71dad6381cd3663de8b6 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:42 +0000 Subject: [PATCH 162/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Input.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 4295425..0a3da23 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -164,8 +164,8 @@ senseWiimote wmdev controller = do -- Obtain positions of leds 1 and 2 (with a normal wii bar, those -- will be the ones we use). - let led1 = irs !! 0 - led2 = irs !! 1 + let led1 = irs !! 0 + led2 = irs !! 1 -- Calculate mid point between sensor bar leds let posX = ((cwiidIRSrcPosX led1) + (cwiidIRSrcPosX led2)) `div` 2 @@ -176,8 +176,8 @@ senseWiimote wmdev controller = do propY = fromIntegral (max 0 (posY - 384)) / 384.0 -- Calculate game area coordinates - let finX = width * propX - finY = height * propY + let finX = width * propX + finY = height * propY -- Direction (old system based on buttons) -- let isLeft = cwiidIsBtnPushed flags cwiidBtnLeft @@ -319,7 +319,7 @@ mat = V.generate 2048 $ \i -> findFirst :: Vector Word16 -> Maybe (Int, Int) findFirst vs = fmap (\v -> (v `mod` 640, v `div` 640)) i - where i = V.findIndex (\x -> mat ! (fromIntegral x) < 512) vs + where i = V.findIndex (\x -> mat ! (fromIntegral x) < 512) vs processPayload :: Vector Word16 -> [(Float, Int, Int)] processPayload ps = [(pval, tx, ty) | i <- [0 .. 640 * 480 - 1] @@ -341,5 +341,4 @@ adjust maxD old new | abs (old - new) < maxD = new | old < new = old + maxD | otherwise = old - maxD - #endif From ef71cc3c369d63021f4ec52ba3ac0841c588be9d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:42 +0000 Subject: [PATCH 163/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Objects.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index c623d20..1443ba3 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -46,10 +46,10 @@ type Objects = [Object] -- -- TODO: Use a GADT to separate these properties in two types and guarantee a -- proper correspondence in 'Object'. -data ObjectKind = Ball Double -- radius? - | Paddle Size2D - | Block Energy Size2D - | Side Side +data ObjectKind = Ball Double -- radius? + | Paddle Size2D + | Block Energy Size2D + | Side Side deriving (Show, Eq) type Energy = Int From 47b270a8a5fc44c69a90e19cf021c50d86587146 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:42 +0000 Subject: [PATCH 164/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Physics/TwoDimensions/Dimensions.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Physics/TwoDimensions/Dimensions.hs b/src/Physics/TwoDimensions/Dimensions.hs index 4a6cde7..867f680 100644 --- a/src/Physics/TwoDimensions/Dimensions.hs +++ b/src/Physics/TwoDimensions/Dimensions.hs @@ -10,8 +10,8 @@ module Physics.TwoDimensions.Dimensions where type Size2D = (Double, Double) -type Pos2D = (Double, Double) +type Pos2D = (Double, Double) -type Vel2D = (Double, Double) +type Vel2D = (Double, Double) -type Acc2D = (Double, Double) +type Acc2D = (Double, Double) From 585109fd247bf58d961a94c415067b2739f6e835 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:28:42 +0000 Subject: [PATCH 165/201] Remove unnecessary space (KSG Haskell 1.3.0 - 4.5.4.3). Refs #103. Do not leave any extra spaces except as mandated or recommended by these rules. --- src/Resources.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources.hs b/src/Resources.hs index f5e9d99..7a76348 100644 --- a/src/Resources.hs +++ b/src/Resources.hs @@ -13,7 +13,7 @@ data ResourceSpec = ResourceSpec , audio :: [AudioResource] } -type FontResource = Resource +type FontResource = Resource type ImageResource = Resource From d52577eeb3d6243fa72713460fb06de9c5fed165 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:30:42 +0000 Subject: [PATCH 166/201] Align imports (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is required for the module names and lists of imported symbols in contiguous import declarations (that is, those beloging to the same group or those without empty lines separating them). --- src/Audio.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Audio.hs b/src/Audio.hs index abedc9d..3a635e3 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -20,14 +20,14 @@ module Audio , musicPlaying) where -- External imports -import Control.Applicative ((<$>)) -import Control.Concurrent -import Control.Monad +import Control.Applicative ((<$>)) +import Control.Concurrent +import Control.Monad import qualified Graphics.UI.SDL.Mixer.Channels as SDL.Mixer.Channels -import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer -import qualified Graphics.UI.SDL.Mixer.Music as SDL.Mixer.Music -import qualified Graphics.UI.SDL.Mixer.Samples as SDL.Mixer.Samples -import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types +import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer +import qualified Graphics.UI.SDL.Mixer.Music as SDL.Mixer.Music +import qualified Graphics.UI.SDL.Mixer.Samples as SDL.Mixer.Samples +import qualified Graphics.UI.SDL.Mixer.Types as SDL.Mixer.Types data Music = Music { musicName :: String, unMusic :: SDL.Mixer.Types.Music } From 8dfe1bb57559001832f87021a81523f626a631ec Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:31:20 +0000 Subject: [PATCH 167/201] Align imports (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is required for the module names and lists of imported symbols in contiguous import declarations (that is, those beloging to the same group or those without empty lines separating them). --- src/Display.hs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index d6d5b0e..ca34d24 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -7,17 +7,17 @@ module Display where -- External imports -import Control.Applicative ((<$>)) -import Control.Monad -import Control.Monad.IfElse -import Control.Monad.IO.Class -import Control.Monad.Trans.Class -import Control.Monad.Trans.Maybe -import Data.IORef -import Data.Maybe -import Graphics.UI.SDL as SDL -import Graphics.UI.SDL.Image as Image -import qualified Graphics.UI.SDL.TTF as TTF +import Control.Applicative ((<$>)) +import Control.Monad +import Control.Monad.IO.Class +import Control.Monad.IfElse +import Control.Monad.Trans.Class +import Control.Monad.Trans.Maybe +import Data.IORef +import Data.Maybe +import Graphics.UI.SDL as SDL +import Graphics.UI.SDL.Image as Image +import qualified Graphics.UI.SDL.TTF as TTF -- Internal imports import Audio @@ -26,7 +26,7 @@ import GameState import Levels import Objects import Paths_haskanoid -import Resources hiding (audio) +import Resources hiding (audio) -- * Initialization From 0e0e57d4f1db27f141ea339866f989b437be65e1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:31:20 +0000 Subject: [PATCH 168/201] Align imports (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is required for the module names and lists of imported symbols in contiguous import declarations (that is, those beloging to the same group or those without empty lines separating them). --- src/Input.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 0a3da23..5f15e15 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -41,19 +41,19 @@ import Graphics.UI.SDL as SDL -- External imports (Wiimote) #ifdef wiimote +import Control.Monad (void) import Control.Monad.IfElse (awhen) -import Control.Monad(void) -import Data.Maybe (fromMaybe) +import Data.Maybe (fromMaybe) import System.CWiid #endif -- External imports (Kinect) #ifdef kinect -import Control.Concurrent -import Data.Vector.Storable (Vector, (!)) +import Control.Concurrent +import Data.Vector.Storable (Vector, (!)) import qualified Data.Vector.Storable as V -import Data.Word -import Freenect +import Data.Word +import Freenect #endif -- Internal imports From 07beaf301ded92218320f97f79cc2f84197debed Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:31:20 +0000 Subject: [PATCH 169/201] Align imports (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is required for the module names and lists of imported symbols in contiguous import declarations (that is, those beloging to the same group or those without empty lines separating them). --- src/Levels.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index cd3435a..4eff360 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -18,7 +18,7 @@ module Levels where -- External imports import Control.Arrow (first, (***)) -import Data.List (nub) +import Data.List (nub) -- Internal imports import Constants From 453fa3e4ee277fef8ee9ad4bf135098bc57dcff9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:31:20 +0000 Subject: [PATCH 170/201] Align imports (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is required for the module names and lists of imported symbols in contiguous import declarations (that is, those beloging to the same group or those without empty lines separating them). --- src/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Main.hs b/src/Main.hs index a710fff..cb7782a 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,7 +1,7 @@ -- External imports -import Control.Applicative ((<$>)) +import Control.Applicative ((<$>)) import Control.Monad.IfElse -import FRP.Yampa as Yampa +import FRP.Yampa as Yampa -- Internal imports import Display From 06fa3239050d19ee942bb34d3671653772797189 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:55:24 +0000 Subject: [PATCH 171/201] Horizontally align expressions (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is strongly encourage for commas in comma-separated fields listed in multiple lines, for the arguments and the equals sign of small function left-hand sides with the same structure. --- src/Levels.hs | 271 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 163 insertions(+), 108 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 4eff360..8b5c2d1 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -160,8 +160,9 @@ blockDescS :: Int -> [(Pos2D, Int)] blockDescS 0 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] ] blockRows :: Num a => a @@ -179,9 +180,10 @@ blockDescS 0 = map (first adjustPos) allBlocks blockDescS 1 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Ord a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x + y > 2) && (x + y < 10) + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x + y > 2) && (x + y < 10) ] blockRows :: Num a => a @@ -191,9 +193,10 @@ blockDescS 1 = map (first adjustPos) allBlocks blockDescS 2 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= y && (blockColumns - 1 - x) /= y + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= y && (blockColumns - 1 - x) /= y ] blockRows :: Num a => a @@ -209,10 +212,10 @@ blockDescS 2 = map (first adjustPos) allBlocks blockDescS 3 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , ((even x) && (odd y) || - (odd x) && (even y)) + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , ((even x) && (odd y) || (odd x) && (even y)) ] blockRows :: Num a => a @@ -230,12 +233,18 @@ blockDescS 3 = map (first adjustPos) allBlocks blockDescS 4 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1]] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [2], odd x] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [4], even x] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [2], odd x + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [4], even x + ] blockRows :: Num a => a blockRows = 7 @@ -250,7 +259,7 @@ blockDescS 5 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] allBlocks = nub $ - [((3, 0), maxBlockLife), ((blockColumns - 4, 1), maxBlockLife)] + [((3, 0), maxBlockLife), ((blockColumns - 4, 1), maxBlockLife)] ++ [((2, 1), maxBlockLife), ((blockColumns - 3, 1), maxBlockLife)] ++ [((1, 2), maxBlockLife), ((blockColumns - 2, 2), maxBlockLife)] ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] @@ -265,10 +274,14 @@ blockDescS 5 = map (first adjustPos) allBlocks blockDescS 6 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x, y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1..blockRows - 2]] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0, blockColumns - 1] + , y <- [1..blockRows - 2] + ] blockRows :: Num a => a blockRows = 5 @@ -284,12 +297,18 @@ blockDescS 6 = map (first adjustPos) allBlocks blockDescS 7 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1]] - ++ [((x, y), maxBlockLife) | x <- [0, blockColumns - 1] - , y <- [1, blockRows - 2]] - ++ [((x, y), maxBlockLife) | x <- [3, 4] - , y <- [2..4]] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0, blockColumns - 1] + , y <- [1, blockRows - 2] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [3, 4] + , y <- [2..4] + ] blockRows :: Num a => a blockRows = 7 @@ -309,9 +328,11 @@ blockDescS 7 = map (first adjustPos) allBlocks blockDescS 8 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= 2, y /= 2 + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= 2 + , y /= 2 ] blockRows :: Num a => a @@ -329,10 +350,10 @@ blockDescS 8 = map (first adjustPos) allBlocks blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [3], y <- [0..6]] - ++ [((x, y), maxBlockLife) | x <- [0..6], y <- [3]] - ++ [((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5]] - ++ [((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4]] + allBlocks = [ ((x, y), maxBlockLife) | x <- [3], y <- [0..6] ] + ++ [ ((x, y), maxBlockLife) | x <- [0..6], y <- [3] ] + ++ [ ((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5] ] + ++ [ ((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4] ] adjustHPos :: Double -> Double adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) @@ -356,10 +377,16 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks blockDescS 10 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1], odd x] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , odd x + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [midRow] + , even x + ] blockRows :: Num a => a blockRows = 9 @@ -379,9 +406,9 @@ blockDescS 10 = map (first adjustPos) allBlocks blockDescS 11 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | y <- [0 .. blockRows - 1] - , x <- [0 .. (blockColumns - 1) - - (2 * abs (y - midRow))] + allBlocks = [ ((x, y), maxBlockLife) + | y <- [0 .. blockRows - 1] + , x <- [0 .. (blockColumns - 1) - (2 * abs (y - midRow))] ] blockRows :: Num a => a @@ -402,15 +429,19 @@ blockDescS 11 = map (first adjustPos) allBlocks blockDescS 12 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0]] - ++ [((x, y), maxBlockLife) | x <- [2, blockColumns - 3] - , y <- [1, 2]] - ++ [ ((1, 4), maxBlockLife) - , ((blockColumns - 2, 4), maxBlockLife) - , ((0, 5), maxBlockLife) - , ((blockColumns - 1, 5), maxBlockLife) - ] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [2, blockColumns - 3] + , y <- [1, 2] + ] + ++ [ ((1, 4), maxBlockLife) + , ((blockColumns - 2, 4), maxBlockLife) + , ((0, 5), maxBlockLife) + , ((blockColumns - 1, 5), maxBlockLife) + ] blockRows :: Num a => a blockRows = 9 @@ -426,13 +457,14 @@ blockDescS 12 = map (first adjustPos) allBlocks blockDescS 13 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), blockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , let blockLife = - if even (x + y) - then maxBlockLife - else maxBlockLife - 1 - ] + allBlocks = [ ((x, y), blockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , let blockLife = + if even (x + y) + then maxBlockLife + else maxBlockLife - 1 + ] blockRows :: Num a => a blockRows = 4 @@ -450,24 +482,29 @@ blockDescS 13 = map (first adjustPos) allBlocks blockDescS 14 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x == 0) - || (y == 0) - || (x == blockColumns - 1) - || (y == blockRows - 1)] - ++ [((x, y), maxBlockLife - 1) | x <- [1..blockColumns - 2] - , y <- [1..blockRows - 2] - , (x == 1) - || (y == 1) - || (x == blockColumns - 2) - || (y == blockRows - 2)] - ++ [((x, y), maxBlockLife) | x <- [2..blockColumns - 3] - , y <- [2..blockRows - 3] - , (x == 2) - || (y == 2) - || (x == blockColumns - 3) - || (y == blockRows - 3)] + allBlocks = [ ((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x == 0) + || (y == 0) + || (x == blockColumns - 1) + || (y == blockRows - 1)] + + ++ [ ((x, y), maxBlockLife - 1) + | x <- [1..blockColumns - 2] + , y <- [1..blockRows - 2] + , (x == 1) + || (y == 1) + || (x == blockColumns - 2) + || (y == blockRows - 2)] + + ++ [ ((x, y), maxBlockLife) + | x <- [2..blockColumns - 3] + , y <- [2..blockRows - 3] + , (x == 2) + || (y == 2) + || (x == blockColumns - 3) + || (y == blockRows - 3)] blockRows :: Num a => a blockRows = 5 @@ -489,14 +526,21 @@ blockDescS 14 = map (first adjustPos) allBlocks blockDescS 15 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0..midRow], odd x] - ++ [((x, y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [midRow], even x] - ++ [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midRow - + 1..blockColumns - 1] - , even x] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..midRow] + , odd x + ] + ++ [ ((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [midRow] + , even x + ] + ++ [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [midRow + 1..blockColumns - 1] + , even x + ] blockRows :: Num a => a blockRows = 9 @@ -521,18 +565,23 @@ blockDescS 15 = map (first adjustPos) allBlocks blockDescS 16 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = - [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [midColumn - 1, midColumn] - , (even x && y == midColumn) - || (odd x && y == midColumn -1)] - ++ [((x, y), minBlockLife) | x <- [midColumn - 1, midColumn] - , y <- [0, 1, - blockRows - 2, blockRows - 1]] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, 1, - blockRows - 2, blockRows - 1] - , x /= midColumn - 1, x /= midColumn] + allBlocks = [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [midColumn - 1, midColumn] + , (even x && y == midColumn) || (odd x && y == midColumn -1) + ] + + ++ [ ((x, y), minBlockLife) + | x <- [midColumn - 1, midColumn] + , y <- [0, 1, blockRows - 2, blockRows - 1] + ] + + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, 1, blockRows - 2, blockRows - 1] + , x /= midColumn - 1 + , x /= midColumn + ] blockRows :: Num a => a blockRows = 8 @@ -560,17 +609,23 @@ blockDescS 16 = map (first adjustPos) allBlocks blockDescS 17 = map (first adjustPos) allBlocks where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = - [((x, y), maxBlockLife - 1) | x <- [0..blockColumns - 1] - , y <- [3, 4] - , odd x] - ++ [((x, y), minBlockLife) | x <- [0..blockColumns - 1] - , y <- [1, 2, - blockRows - 4, blockRows - 3] - , even x ] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - , y == 0 || x /= midColumn] + allBlocks = [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [3, 4] + , odd x + ] + + ++ [((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [1, 2, blockRows - 4, blockRows - 3] + , even x + ] + + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + , y == 0 || x /= midColumn + ] blockRows :: Num a => a blockRows = 9 From f0c5611e1efebbf86ace6eccb110f1f742f4f83a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 22:56:50 +0000 Subject: [PATCH 172/201] Horizontally align expressions (KSG Haskell 1.3.0 - 4.5.5). Refs #103. Horizontal alignment is strongly encourage for commas in comma-separated fields listed in multiple lines, for the arguments and the equals sign of small function left-hand sides with the same structure. --- src/Objects.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Objects.hs b/src/Objects.hs index 1443ba3..479cc5d 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -60,7 +60,7 @@ isBall _ = False isBlock :: ObjectKind -> Bool isBlock Block {} = True -isBlock _ = False +isBlock _ = False isPaddle :: Object -> Bool isPaddle o = case objectKind o of From 746a1af50db4b966fdb1b173f5ae0a1e0bbbfab0 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:07:31 +0000 Subject: [PATCH 173/201] Remove redundant parenthesis (KSG Haskell 1.3.0 - 4.6). Refs #103. Do not wrap expressions in parenthesis unnecessarily. --- src/FRP/Extra/Yampa.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 37bb355..84b40a8 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -22,10 +22,10 @@ holdWhen bInit sf = sf >>> holdOutput >>> hold bInit -- functions when they exist mergeApply :: SF a b -> SF a (Event (b -> b)) -> SF a b mergeApply sf1 sf2 = - (sf1 &&& sf2) >>> (arr (\(b, ef) -> event b ($ b) ef)) + (sf1 &&& sf2) >>> arr (\(b, ef) -> event b ($ b) ef) mergeApply' :: SF a (b, Event (b -> b)) -> SF a b -mergeApply' sf1 = sf1 >>> (arr (\(b, ef) -> event b ($ b) ef)) +mergeApply' sf1 = sf1 >>> arr (\(b, ef) -> event b ($ b) ef) rRestart :: SF a (b, Event c) -> SF a b rRestart sf = r From d6588cbdce92db9ce0ae33994cf549fe1308c941 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:10:14 +0000 Subject: [PATCH 174/201] Remove redundant parenthesis (KSG Haskell 1.3.0 - 4.6). Refs #103. Do not wrap expressions in parenthesis unnecessarily. --- src/Levels.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Levels.hs b/src/Levels.hs index 8b5c2d1..1240030 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -215,7 +215,7 @@ blockDescS 3 = map (first adjustPos) allBlocks allBlocks = [ ((x, y), maxBlockLife) | x <- [0..blockColumns - 1] , y <- [0..blockRows - 1] - , ((even x) && (odd y) || (odd x) && (even y)) + , even x && odd y || odd x && even y ] blockRows :: Num a => a From f7fa49f27b1a1ba1667a7bfa1d24ee37d333d145 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:22:04 +0000 Subject: [PATCH 175/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Audio.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Audio.hs b/src/Audio.hs index 3a635e3..ce165ad 100644 --- a/src/Audio.hs +++ b/src/Audio.hs @@ -17,7 +17,9 @@ module Audio , playMusic , playFile , stopMusic - , musicPlaying) where + , musicPlaying + ) + where -- External imports import Control.Applicative ((<$>)) From 4127c6e7f2d4d83214d6db15498f760b623f83cd Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:39 +0000 Subject: [PATCH 176/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Control/Extra/Monad.hs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Control/Extra/Monad.hs b/src/Control/Extra/Monad.hs index 9a6e4e9..753c898 100644 --- a/src/Control/Extra/Monad.hs +++ b/src/Control/Extra/Monad.hs @@ -11,16 +11,18 @@ import Control.Monad whileLoopM :: Monad m => m a -> (a -> Bool) -> (a -> m ()) -> m () whileLoopM val cond act = r' - where r' = do v <- val - when (cond v) $ do - act v - whileLoopM val cond act + where + r' = do v <- val + when (cond v) $ do + act v + whileLoopM val cond act foldLoopM :: Monad m => a -> m b -> (b -> Bool) -> (a -> b -> m a) -> m a foldLoopM val sense cond act = r' - where r' = do s <- sense - if cond s - then do - val' <- act val s - foldLoopM val' sense cond act - else return val + where + r' = do s <- sense + if cond s + then do + val' <- act val s + foldLoopM val' sense cond act + else return val From 924240f6052d33981a9421cf5bdd5ab4bc026b54 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:42 +0000 Subject: [PATCH 177/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Display.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Display.hs b/src/Display.hs index ca34d24..5d13c0f 100644 --- a/src/Display.hs +++ b/src/Display.hs @@ -196,13 +196,14 @@ paintObject resources screen object = SDL.blitSurface bI Nothing screen $ Just (SDL.Rect x' y' sz sz) _ -> return () - where format = surfaceGetPixelFormat screen - p = objectPos object - x = round (fst p) - y = round (snd p) - blockImage 3 = block1Img resources - blockImage 2 = block2Img resources - blockImage n = block3Img resources + where + format = surfaceGetPixelFormat screen + p = objectPos object + x = round (fst p) + y = round (snd p) + blockImage 3 = block1Img resources + blockImage 2 = block2Img resources + blockImage n = block3Img resources -- * Resource management From 52bf3c1ec5c8dc0801e887c4040f5181c6e13be1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:44 +0000 Subject: [PATCH 178/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/FRP/Extra/Yampa.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 84b40a8..3d8b53a 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -16,7 +16,8 @@ import FRP.Yampa -- is false, and it holds the last known value when the value is True. holdWhen :: b -> SF a (b, Bool) -> SF a b holdWhen bInit sf = sf >>> holdOutput >>> hold bInit - where holdOutput = arr (\(b, discard) -> if discard then noEvent else Event b) + where + holdOutput = arr (\(b, discard) -> if discard then noEvent else Event b) -- Given an occasional producer of functions and a source of info, apply the -- functions when they exist @@ -29,7 +30,8 @@ mergeApply' sf1 = sf1 >>> arr (\(b, ef) -> event b ($ b) ef) rRestart :: SF a (b, Event c) -> SF a b rRestart sf = r - where r = switch sf (const r) + where + r = switch sf (const r) futureSwitch :: SF a (b, Event c) -> (c -> SF a b) -> SF a b futureSwitch sf cont = switch (sf >>> (arr id *** notYet)) cont From 5f915b6e8261c5d2c8f4130c71307a05d4400632 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:48 +0000 Subject: [PATCH 179/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/GameCollisions.hs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index adea98b..5bd2262 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -31,16 +31,18 @@ import Physics.TwoDimensions.Dimensions -- detectCollisions :: IL Object -> Collisions detectCollisions = detectCollisionsH - where detectCollisionsH objsT = flattened - where -- Eliminate empty collision sets - -- TODO: why is this really necessary? - flattened = filter (\(Collision n) -> not (null n)) collisions + where + detectCollisionsH objsT = flattened + where + -- Eliminate empty collision sets + -- TODO: why is this really necessary? + flattened = filter (\(Collision n) -> not (null n)) collisions - -- Detect collisions between moving objects and any other objects - collisions = detectCollisions' objsT moving + -- Detect collisions between moving objects and any other objects + collisions = detectCollisions' objsT moving - -- Partition the object space between moving and static objects - (moving, _static) = partition (canCauseCollisions.snd) $ assocsIL objsT + -- Partition the object space between moving and static objects + (moving, _static) = partition (canCauseCollisions.snd) $ assocsIL objsT -- | Detect collisions between each moving object and every other object. detectCollisions' :: IL Object -> [(ILKey, Object)] -> [Collision] From 175b5c7d7e813d99cba97d75e7d12a81999f2d2f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:52 +0000 Subject: [PATCH 180/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Game.hs | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 5ca8efc..2fe9e15 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -313,9 +313,10 @@ gamePlay' objs = loopPre ([], [], 0) $ -- Turn every object that wants to kill itself into a function that -- removes it from the list - where es :: [Event (IL ObjectSF -> IL ObjectSF)] - es = [ harakiri oo `tag` deleteIL k - | (k, oo) <- assocsIL oos ] + where + es :: [Event (IL ObjectSF -> IL ObjectSF)] + es = [ harakiri oo `tag` deleteIL k + | (k, oo) <- assocsIL oos ] -- From the actual objects, detect which ones collide detectObjectCollisions :: SF (IL ObjectOutput) Collisions @@ -324,11 +325,12 @@ gamePlay' objs = loopPre ([], [], 0) $ -- Count-points countPoints :: Collisions -> Int countPoints = sum . map numPoints - where numPoints (Collision cd) - | hasBall cd = countBlocks cd - | otherwise = 0 - hasBall = any ((=="ball").fst) - countBlocks = length . filter (isPrefixOf "block" . fst) + where + numPoints (Collision cd) + | hasBall cd = countBlocks cd + | otherwise = 0 + hasBall = any ((=="ball").fst) + countBlocks = length . filter (isPrefixOf "block" . fst) -- * Game objects -- @@ -391,18 +393,19 @@ followPaddle = arr $ \oi -> ((paddleWidth / 2, - ballHeight) ^+^) mbPaddlePos in ObjectOutput (inertBallAt ballPos) noEvent - where outOfScreen = -10 - inertBallAt p = Object { objectName = "ball" - , objectKind = Ball ballWidth - , objectPos = p - , objectVel = (0, 0) - , objectAcc = (0, 0) - , objectDead = False - , objectHit = False - , canCauseCollisions = False - , collisionEnergy = 0 - , displacedOnCollision = False - } + where + outOfScreen = -10 + inertBallAt p = Object { objectName = "ball" + , objectKind = Ball ballWidth + , objectPos = p + , objectVel = (0, 0) + , objectAcc = (0, 0) + , objectDead = False + , objectHit = False + , canCauseCollisions = False + , collisionEnergy = 0 + , displacedOnCollision = False + } -- A bouncing ball moves freely until there is a collision, then bounces and -- goes on and on. From da16b05b777947813002290c5ce7ba3c2ae4a972 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:25:58 +0000 Subject: [PATCH 181/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Input.hs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 5f15e15..5251cee 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -107,7 +107,8 @@ initializeInputDevices = do nr <- newIORef defaultInfo return $ ControllerRef (nr, dev') - where defaultInfo = Controller (0, 0) False False False + where + defaultInfo = Controller (0, 0) False False False -- | Sense from the controller, providing its current state. This should return -- a new Controller state if available, or the last one there was. @@ -285,8 +286,9 @@ getDepthThread screenSize lastPos = forkIO $ do startDepth device forever $ processEvents context - where devices = [Camera] - index = 0 :: Integer + where + devices = [Camera] + index = 0 :: Integer updatePos :: IORef (Maybe (Double, Double)) -> (Double, Double) -> IO () updatePos lastPosRef newPos@(nx, ny) = do @@ -302,14 +304,15 @@ calculateMousePos :: (Double, Double) -> Maybe (Double, Double) calculateMousePos (width, height) payload = fmap g (findFirst payload) - where g (px, py) = (mousex, mousey) - where - pointerx = fromIntegral (640 - px) - pointery = fromIntegral py - mousex = pointerx -- pointerx * adjx - mousey = pointery -- pointery * adjy - adjx = width / 630.0 - adjy = height / 470.0 + where + g (px, py) = (mousex, mousey) + where + pointerx = fromIntegral (640 - px) + pointery = fromIntegral py + mousex = pointerx -- pointerx * adjx + mousey = pointery -- pointery * adjy + adjx = width / 630.0 + adjy = height / 470.0 mat :: Vector Float mat = V.generate 2048 $ \i -> @@ -319,7 +322,8 @@ mat = V.generate 2048 $ \i -> findFirst :: Vector Word16 -> Maybe (Int, Int) findFirst vs = fmap (\v -> (v `mod` 640, v `div` 640)) i - where i = V.findIndex (\x -> mat ! (fromIntegral x) < 512) vs + where + i = V.findIndex (\x -> mat ! (fromIntegral x) < 512) vs processPayload :: Vector Word16 -> [(Float, Int, Int)] processPayload ps = [(pval, tx, ty) | i <- [0 .. 640 * 480 - 1] @@ -332,8 +336,9 @@ processPayload ps = [(pval, tx, ty) | i <- [0 .. 640 * 480 - 1] -- Drop the fst elem, calculate the avg of snd and trd over the whole list avg :: [(Float, Int, Int)] -> (Int, Int) avg ls = (sumx `div` l, sumy `div` l) - where l = length ls - (sumx, sumy) = foldr (\(_, x, y) (rx, ry) -> (x + rx, y + ry)) (0, 0) ls + where + l = length ls + (sumx, sumy) = foldr (\(_, x, y) (rx, ry) -> (x + rx, y + ry)) (0, 0) ls -- Update a value, with a max cap adjust :: (Num a, Ord a) => a -> a -> a -> a From 83ac3e0ffe6c74a8d456a25e4253ed1b2b861aec Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:26:12 +0000 Subject: [PATCH 182/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Levels.hs | 490 +++++++++++++++++++++++++++----------------------- 1 file changed, 262 insertions(+), 228 deletions(-) diff --git a/src/Levels.hs b/src/Levels.hs index 1240030..0f6f314 100644 --- a/src/Levels.hs +++ b/src/Levels.hs @@ -159,14 +159,16 @@ levels = [ -- Level 0 blockDescS :: Int -> [(Pos2D, Int)] blockDescS 0 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - ] + where + + allBlocks :: (Enum a, Num a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + ] - blockRows :: Num a => a - blockRows = 4 + blockRows :: Num a => a + blockRows = 4 -- Level 1 -- %%%%%%%% @@ -211,15 +213,17 @@ blockDescS 2 = map (first adjustPos) allBlocks -- % X X X X blockDescS 3 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , even x && odd y || odd x && even y - ] + where - blockRows :: Num a => a - blockRows = 4 + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , even x && odd y || odd x && even y + ] + + blockRows :: Num a => a + blockRows = 4 -- Level 4 -- %%%%%%%% @@ -232,22 +236,24 @@ blockDescS 3 = map (first adjustPos) allBlocks -- % XXXXXXXX blockDescS 4 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - ] - ++ [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [2], odd x - ] - ++ [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [4], even x - ] - - blockRows :: Num a => a - blockRows = 7 + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [2], odd x + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [4], even x + ] + + blockRows :: Num a => a + blockRows = 7 -- Level 5 -- %%%%%%%% @@ -257,12 +263,14 @@ blockDescS 4 = map (first adjustPos) allBlocks -- % XXXXXXX blockDescS 5 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = nub $ - [((3, 0), maxBlockLife), ((blockColumns - 4, 1), maxBlockLife)] - ++ [((2, 1), maxBlockLife), ((blockColumns - 3, 1), maxBlockLife)] - ++ [((1, 2), maxBlockLife), ((blockColumns - 2, 2), maxBlockLife)] - ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = nub $ + [((3, 0), maxBlockLife), ((blockColumns - 4, 1), maxBlockLife)] + ++ [((2, 1), maxBlockLife), ((blockColumns - 3, 1), maxBlockLife)] + ++ [((1, 2), maxBlockLife), ((blockColumns - 2, 2), maxBlockLife)] + ++ [((x, y), maxBlockLife) | x <- [0..blockColumns - 1], y <- [3]] -- Level 6 -- %%%%%%%% @@ -273,18 +281,20 @@ blockDescS 5 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 6 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1] - ] - ++ [ ((x, y), maxBlockLife) - | x <- [0, blockColumns - 1] - , y <- [1..blockRows - 2] - ] + where - blockRows :: Num a => a - blockRows = 5 + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0, blockColumns - 1] + , y <- [1..blockRows - 2] + ] + + blockRows :: Num a => a + blockRows = 5 -- Level 7 -- %%%%%%%% @@ -296,22 +306,24 @@ blockDescS 6 = map (first adjustPos) allBlocks -- % XXXXXX blockDescS 7 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [1..blockColumns - 2] - , y <- [0, blockRows - 1] - ] - ++ [ ((x, y), maxBlockLife) - | x <- [0, blockColumns - 1] - , y <- [1, blockRows - 2] - ] - ++ [ ((x, y), maxBlockLife) - | x <- [3, 4] - , y <- [2..4] - ] - - blockRows :: Num a => a - blockRows = 7 + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [1..blockColumns - 2] + , y <- [0, blockRows - 1] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0, blockColumns - 1] + , y <- [1, blockRows - 2] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [3, 4] + , y <- [2..4] + ] + + blockRows :: Num a => a + blockRows = 7 -- Level 8 -- %%%%%%%% @@ -327,16 +339,18 @@ blockDescS 7 = map (first adjustPos) allBlocks -- % XX XXXXX blockDescS 8 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , x /= 2 - , y /= 2 - ] + where - blockRows :: Num a => a - blockRows = 9 + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , x /= 2 + , y /= 2 + ] + + blockRows :: Num a => a + blockRows = 9 -- Level 9 -- %%%%%%%% @@ -349,19 +363,22 @@ blockDescS 8 = map (first adjustPos) allBlocks -- % X blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) | x <- [3], y <- [0..6] ] - ++ [ ((x, y), maxBlockLife) | x <- [0..6], y <- [3] ] - ++ [ ((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5] ] - ++ [ ((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4] ] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) | x <- [3], y <- [0..6] ] + ++ [ ((x, y), maxBlockLife) | x <- [0..6], y <- [3] ] + ++ [ ((x, y), maxBlockLife) | x <- [2, 4], y <- [1, 5] ] + ++ [ ((x, y), maxBlockLife) | x <- [1, 5], y <- [2, 4] ] - adjustHPos :: Double -> Double - adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) + adjustHPos :: Double -> Double + adjustHPos = (leftMargin +) . ((blockWidth + blockSeparation) *) - leftMargin :: Num a => a - leftMargin = - round' ((gameWidth - (blockWidth + blockSeparation) * 7) / 2) - where round' = fromIntegral . floor + leftMargin :: Num a => a + leftMargin = + round' ((gameWidth - (blockWidth + blockSeparation) * 7) / 2) + where + round' = fromIntegral . floor -- Level 10 -- %%%%%%%% @@ -376,23 +393,25 @@ blockDescS 9 = map (first ((adjustHPos *** adjustVPos) . fI2)) allBlocks -- % X X X blockDescS 10 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , odd x - ] - ++ [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [midRow] - , even x - ] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , odd x + ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [midRow] + , even x + ] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 -- Level 11 -- %%%%%%%% @@ -405,17 +424,19 @@ blockDescS 10 = map (first adjustPos) allBlocks -- % XX blockDescS 11 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | y <- [0 .. blockRows - 1] - , x <- [0 .. (blockColumns - 1) - (2 * abs (y - midRow))] - ] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | y <- [0 .. blockRows - 1] + , x <- [0 .. (blockColumns - 1) - (2 * abs (y - midRow))] + ] - blockRows :: Num a => a - blockRows = 7 + blockRows :: Num a => a + blockRows = 7 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 -- Level 12 -- %%%%%%%% @@ -428,23 +449,25 @@ blockDescS 11 = map (first adjustPos) allBlocks blockDescS 12 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0] - ] - ++ [ ((x, y), maxBlockLife) - | x <- [2, blockColumns - 3] - , y <- [1, 2] - ] - ++ [ ((1, 4), maxBlockLife) - , ((blockColumns - 2, 4), maxBlockLife) - , ((0, 5), maxBlockLife) - , ((blockColumns - 1, 5), maxBlockLife) - ] - - blockRows :: Num a => a - blockRows = 9 + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0] + ] + ++ [ ((x, y), maxBlockLife) + | x <- [2, blockColumns - 3] + , y <- [1, 2] + ] + ++ [ ((1, 4), maxBlockLife) + , ((blockColumns - 2, 4), maxBlockLife) + , ((0, 5), maxBlockLife) + , ((blockColumns - 1, 5), maxBlockLife) + ] + + blockRows :: Num a => a + blockRows = 9 -- Level 13 -- X == maxBlockLife @@ -456,18 +479,20 @@ blockDescS 12 = map (first adjustPos) allBlocks -- % OXOXOXOX blockDescS 13 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), blockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , let blockLife = - if even (x + y) - then maxBlockLife - else maxBlockLife - 1 - ] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), blockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , let blockLife = + if even (x + y) + then maxBlockLife + else maxBlockLife - 1 + ] - blockRows :: Num a => a - blockRows = 4 + blockRows :: Num a => a + blockRows = 4 -- Level 14 -- X == maxBlockLife @@ -481,33 +506,35 @@ blockDescS 13 = map (first adjustPos) allBlocks -- % YYYYYYYY blockDescS 14 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), minBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..blockRows - 1] - , (x == 0) - || (y == 0) - || (x == blockColumns - 1) - || (y == blockRows - 1)] - - ++ [ ((x, y), maxBlockLife - 1) - | x <- [1..blockColumns - 2] - , y <- [1..blockRows - 2] - , (x == 1) - || (y == 1) - || (x == blockColumns - 2) - || (y == blockRows - 2)] - - ++ [ ((x, y), maxBlockLife) - | x <- [2..blockColumns - 3] - , y <- [2..blockRows - 3] - , (x == 2) - || (y == 2) - || (x == blockColumns - 3) - || (y == blockRows - 3)] - - blockRows :: Num a => a - blockRows = 5 + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..blockRows - 1] + , (x == 0) + || (y == 0) + || (x == blockColumns - 1) + || (y == blockRows - 1)] + + ++ [ ((x, y), maxBlockLife - 1) + | x <- [1..blockColumns - 2] + , y <- [1..blockRows - 2] + , (x == 1) + || (y == 1) + || (x == blockColumns - 2) + || (y == blockRows - 2)] + + ++ [ ((x, y), maxBlockLife) + | x <- [2..blockColumns - 3] + , y <- [2..blockRows - 3] + , (x == 2) + || (y == 2) + || (x == blockColumns - 3) + || (y == blockRows - 3)] + + blockRows :: Num a => a + blockRows = 5 -- Level 15 -- maxBlockLife == X @@ -525,28 +552,30 @@ blockDescS 14 = map (first adjustPos) allBlocks -- % T T T blockDescS 15 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0..midRow] - , odd x - ] - ++ [ ((x, y), minBlockLife) - | x <- [0..blockColumns - 1] - , y <- [midRow] - , even x - ] - ++ [ ((x, y), maxBlockLife - 1) - | x <- [0..blockColumns - 1] - , y <- [midRow + 1..blockColumns - 1] - , even x - ] - - blockRows :: Num a => a - blockRows = 9 - - midRow :: Integral a => a - midRow = blockRows `div` 2 + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0..midRow] + , odd x + ] + ++ [ ((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [midRow] + , even x + ] + ++ [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [midRow + 1..blockColumns - 1] + , even x + ] + + blockRows :: Num a => a + blockRows = 9 + + midRow :: Integral a => a + midRow = blockRows `div` 2 -- Level 16 -- maxBlockLife == X @@ -564,33 +593,35 @@ blockDescS 15 = map (first adjustPos) allBlocks blockDescS 16 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife - 1) - | x <- [0..blockColumns - 1] - , y <- [midColumn - 1, midColumn] - , (even x && y == midColumn) || (odd x && y == midColumn -1) - ] + where - ++ [ ((x, y), minBlockLife) - | x <- [midColumn - 1, midColumn] - , y <- [0, 1, blockRows - 2, blockRows - 1] - ] + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [midColumn - 1, midColumn] + , (even x && y == midColumn) || (odd x && y == midColumn -1) + ] - ++ [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0, 1, blockRows - 2, blockRows - 1] - , x /= midColumn - 1 - , x /= midColumn - ] + ++ [ ((x, y), minBlockLife) + | x <- [midColumn - 1, midColumn] + , y <- [0, 1, blockRows - 2, blockRows - 1] + ] - blockRows :: Num a => a - blockRows = 8 + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, 1, blockRows - 2, blockRows - 1] + , x /= midColumn - 1 + , x /= midColumn + ] + + blockRows :: Num a => a + blockRows = 8 - midRow :: Integral a => a - midRow = blockRows `div` 2 + midRow :: Integral a => a + midRow = blockRows `div` 2 - midColumn :: Integral a => a - midColumn = blockColumns `div` 2 + midColumn :: Integral a => a + midColumn = blockColumns `div` 2 -- Level 17 -- maxBlockLife == X @@ -608,30 +639,32 @@ blockDescS 16 = map (first adjustPos) allBlocks -- % XXX XXXX blockDescS 17 = map (first adjustPos) allBlocks - where allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] - allBlocks = [ ((x, y), maxBlockLife - 1) - | x <- [0..blockColumns - 1] - , y <- [3, 4] - , odd x - ] + where + + allBlocks :: (Enum a, Num a, Eq a, Integral a) => [((a, a), Int)] + allBlocks = [ ((x, y), maxBlockLife - 1) + | x <- [0..blockColumns - 1] + , y <- [3, 4] + , odd x + ] - ++ [((x, y), minBlockLife) - | x <- [0..blockColumns - 1] - , y <- [1, 2, blockRows - 4, blockRows - 3] - , even x - ] + ++ [((x, y), minBlockLife) + | x <- [0..blockColumns - 1] + , y <- [1, 2, blockRows - 4, blockRows - 3] + , even x + ] - ++ [ ((x, y), maxBlockLife) - | x <- [0..blockColumns - 1] - , y <- [0, blockRows - 1] - , y == 0 || x /= midColumn - ] + ++ [ ((x, y), maxBlockLife) + | x <- [0..blockColumns - 1] + , y <- [0, blockRows - 1] + , y == 0 || x /= midColumn + ] - blockRows :: Num a => a - blockRows = 9 + blockRows :: Num a => a + blockRows = 9 - midColumn :: Integral a => a - midColumn = blockColumns `div` 2 + midColumn :: Integral a => a + midColumn = blockColumns `div` 2 blockDescS _ = error "No more levels" @@ -652,7 +685,8 @@ blockColumns = 1 + round' ( (gameWidth - blockWidth - 2 * leftMargin) / (blockWidth + blockSeparation) ) - where round' = fromIntegral . floor + where + round' = fromIntegral . floor -- * Constants From 3ade8b8a3e57e01bc4f9f7e591b7c01a678ae81a Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:26:15 +0000 Subject: [PATCH 183/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Objects.hs | 56 ++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/Objects.hs b/src/Objects.hs index 479cc5d..f568b8a 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -73,14 +73,17 @@ objShape obj = case objectKind obj of (Paddle s) -> Rectangle p s (Block _ s) -> Rectangle p s (Side s) -> sideToShape p s - where p = objectPos obj - width' = gameWidth - height' = gameHeight - d = collisionErrorMargin - sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2 * d, d) - sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2 * d) - sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2 * d) - sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2 * d, d) + + where + + p = objectPos obj + width' = gameWidth + height' = gameHeight + d = collisionErrorMargin + sideToShape p TopSide = Rectangle (p ^-^ (d, d)) (width' + 2 * d, d) + sideToShape p LeftSide = Rectangle (p ^-^ (d, d)) (d, height' + 2 * d) + sideToShape p RightSide = Rectangle (p ^-^ (0, d)) (d, height' + 2 * d) + sideToShape p BottomSide = Rectangle (p ^-^ (d, 0)) (width' + 2 * d, d) -- * Collisions type Collisions = [Collision] @@ -113,20 +116,23 @@ collisionResponseObj :: Object -> Object -> Collision collisionResponseObj o1 o2 = Collision $ map objectToCollision [(o1, side, o2), (o2, side', o1)] - where side = collisionSide o1 o2 - side' = oppositeSide side - - objectReacts o = collisionEnergy o > 0 || displacedOnCollision o - - objectToCollision (o, s, o') = - ( objectName o - , correctVel - (objectVel o ^+^ (velTrans *^ objectVel o')) - (collisionEnergy o) - s - ) - - correctVel (vx, vy) e TopSide = (vx, ensurePos (vy * (-e))) - correctVel (vx, vy) e BottomSide = (vx, ensureNeg (vy * (-e))) - correctVel (vx, vy) e LeftSide = (ensureNeg (vx * (-e)), vy) - correctVel (vx, vy) e RightSide = (ensurePos (vx * (-e)), vy) + + where + + side = collisionSide o1 o2 + side' = oppositeSide side + + objectReacts o = collisionEnergy o > 0 || displacedOnCollision o + + objectToCollision (o, s, o') = + ( objectName o + , correctVel + (objectVel o ^+^ (velTrans *^ objectVel o')) + (collisionEnergy o) + s + ) + + correctVel (vx, vy) e TopSide = (vx, ensurePos (vy * (-e))) + correctVel (vx, vy) e BottomSide = (vx, ensureNeg (vy * (-e))) + correctVel (vx, vy) e LeftSide = (ensureNeg (vx * (-e)), vy) + correctVel (vx, vy) e RightSide = (ensurePos (vx * (-e)), vy) From 1637e61d7872093f8ce649bc655ee71dc88bf3b4 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:26:16 +0000 Subject: [PATCH 184/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Physics/TwoDimensions/Collisions.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Physics/TwoDimensions/Collisions.hs b/src/Physics/TwoDimensions/Collisions.hs index b2c9b93..c741094 100644 --- a/src/Physics/TwoDimensions/Collisions.hs +++ b/src/Physics/TwoDimensions/Collisions.hs @@ -39,7 +39,8 @@ shapeCollisionSide (Rectangle p1 s1) (Rectangle p2 s2) | wy > hx = LeftSide | wy > -hx = RightSide | otherwise = BottomSide - where (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) -- p1 ^-^ p2 - (w, h) = 0.5 *^ (s1 ^+^ s2) - wy = w * dy - hx = h * dx + where + (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) -- p1 ^-^ p2 + (w, h) = 0.5 *^ (s1 ^+^ s2) + wy = w * dy + hx = h * dx From 69c48aac2aed171a4d7e71e05e540d3cee3638a1 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:26:17 +0000 Subject: [PATCH 185/201] Place where in single line (KSG Haskell 1.3.0 - 5.2). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer where appearing alone on a single line, not at the end of a line or on the same line as the definition it introduces. --- src/Physics/TwoDimensions/Physics.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 1dbdca9..1db34a2 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -26,5 +26,6 @@ data Shape = Rectangle Pos2D Size2D -- A corner and the whole size overlapShape :: Shape -> Shape -> Bool overlapShape (Rectangle p1 s1) (Rectangle p2 s2) = abs dx <= w && abs dy <= h - where (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) - (w, h) = 0.5 *^ (s1 ^+^ s2) + where + (dx, dy) = (p1 ^+^ (0.5 *^ s1)) ^-^ (p2 ^+^ (0.5 *^ s2)) + (w, h) = 0.5 *^ (s1 ^+^ s2) From 2d9f234314448ef05aa928ab1834af24d4821873 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:10 +0000 Subject: [PATCH 186/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/Game.hs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Game.hs b/src/Game.hs index 2fe9e15..b10f3dd 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -249,7 +249,7 @@ composeGameState' lives level pts = proc (oos, dead, points) -> do -- | Given an initial list of objects, it runs the game, presenting the output -- from those objects at all times, notifying any time the ball hits the floor, --- and and of any additional points made. +-- and of any additional points made. -- -- This works as a game loop with a post-processing step. It uses a -- well-defined initial accumulator and a traditional feedback loop. @@ -307,7 +307,7 @@ gamePlay' objs = loopPre ([], [], 0) $ suicidalSect :: (a, IL ObjectOutput) -> Event (IL ObjectSF -> IL ObjectSF) suicidalSect (_, oos) = -- Turn every event carrying a function that transforms the object - -- signal function list into one function that performs all the efects + -- signal function list into one function that performs all the effects -- in sequence foldl (mergeBy (.)) noEvent es @@ -384,7 +384,7 @@ collisionWithBottom = inCollisionWith "ball" "bottomWall" ^>> edge -- otherwise). To avoid reacting to collisions, this ball is non-interactive. followPaddle :: ObjectSF followPaddle = arr $ \oi -> - -- Calculate ball position, midway on top of the the paddle + -- Calculate ball position, midway on top of the paddle -- -- This code allows for the paddle not to exist (Maybe), although that -- should never happen in practice. @@ -424,7 +424,7 @@ bouncingBall p0 v0 = -- Calculate the future tentative position, and bounce if necessary. -- -- The ballBounce needs the ball SF' input (which has knowledge of - -- collisions), so we carry it parallely to the tentative new positions, + -- collisions), so we carry it parallelly to the tentative new positions, -- and then use it to detect when it's time to bounce -- ========================== ============================ @@ -436,7 +436,7 @@ bouncingBall p0 v0 = -- ========================== ============================ progressAndBounce = (arr id &&& freeBall') >>> (arr snd &&& ballBounce) - -- Position of the ball, starting from p0 with velicity v0, since the + -- Position of the ball, starting from p0 with velocity v0, since the -- time of last switching (or being fired, whatever happened last) -- provided that no obstacles are encountered. freeBall' = freeBall p0 v0 @@ -468,7 +468,7 @@ ballBounce' = proc (ObjectInput ci cs os, o) -> do let ev = maybe noEvent Event (changedVelocity "ball" cs) returnA -< fmap (\v -> (objectPos (outputObject o), v)) ev --- | Position of the ball, starting from p0 with velicity v0, since the time of +-- | Position of the ball, starting from p0 with velocity v0, since the time of -- last switching (that is, collision, or the beginning of time --being fired -- from the paddle-- if never switched before), provided that no obstacles are -- encountered. @@ -562,9 +562,9 @@ yPosPaddle = gameHeight - paddleMargin -- *** Blocks --- | Block SF generator. It uses the blocks's size, position and a number of +-- | Block SF generator. It uses the blocks' size, position and a number of -- lives that the block has. The block's position is used for it's unique ID, --- which means that two simulatenously existing blocks should never have the +-- which means that two simultaneously existing blocks should never have the -- same position. This is ok in this case because they are static, but would not -- work if they could move and be created dynamically. objBlock :: (Pos2D, Int) -> Size2D -> ObjectSF @@ -613,10 +613,10 @@ objBlock ((x, y), initlives) (w, h) = proc (ObjectInput ci cs os) -> do -- The function that turns walls into 'Shape's for collision detection -- determines how big they really are. In particular, this has implications in -- ball-through-paper effects (ball going through objects, potentially never --- coming back), which can be seen if the FPS suddently drops due to CPU load +-- coming back), which can be seen if the FPS suddenly drops due to CPU load -- (for instance, if a really major Garbage Collection kicks in. One potential -- optimisation is to trigger these with every SF iteration or every rendering, --- to decrease the workload and thus the likelyhood of BTP effects. +-- to decrease the workload and thus the likelihood of BTP effects. objSideRight :: ObjectSF objSideRight = objWall "rightWall" RightSide (gameWidth, 0) From 7fc5aa2bea1bf4541284680e0d7775896acf7ff3 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 187/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/GameCollisions.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index 5bd2262..b294efd 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -49,7 +49,7 @@ detectCollisions' :: IL Object -> [(ILKey, Object)] -> [Collision] detectCollisions' objsT ms = concatMap (detectCollisions'' objsT) ms -- | Detect collisions between one specific moving object and every existing --- object. Each collision is idependent of the rest (which is not necessarily +-- object. Each collision is independent of the rest (which is not necessarily -- what should happen, but since the transformed velocities are eventually -- added, there isn't much difference in the end). detectCollisions'' :: IL Object -> (ILKey, Object) -> [Collision] @@ -109,7 +109,7 @@ detectCollisions''' m o -- spawning a stateful collision detector when two objects are getting close? -- Cf. the old tail-gating approach. -- - Maybe a collision should also carry the identity of the object one --- collieded with to facilitate impl. of "inCollisionWith". +-- collided with to facilitate impl. of "inCollisionWith". -- changedVelocity :: ObjectName -> Collisions -> Maybe Vel2D changedVelocity name cs = From 1ba3764876e118b456ecddb06e5f06ba47dab3fb Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 188/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/GameState.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GameState.hs b/src/GameState.hs index 940c370..2f30c3f 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -22,7 +22,7 @@ import Objects -- -- Different parts of the game deal with these data structures. It is -- therefore convenient to group them in subtrees, even if there's no --- substantial difference betweem them. +-- substantial difference between them. data GameState = GameState { gameObjects :: Objects , gameInfo :: GameInfo @@ -35,7 +35,7 @@ neutralGameState = GameState , gameInfo = neutralGameInfo } --- | The gameinfo tells us the current game state (running, paused, etc.) and +-- | The GameInfo tells us the current game state (running, paused, etc.) and -- general information, in this case, the number of lives, the level and the -- points. -- From 1409e39af021ca457da852a630d2466865705203 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 189/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/Input.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Input.hs b/src/Input.hs index 5251cee..9b02595 100644 --- a/src/Input.hs +++ b/src/Input.hs @@ -7,7 +7,7 @@ -- -- Defines an abstraction for the game controller and the functions to read it. -- --- Lower-level devices replicate the higher-level API, and should accomodate to +-- Lower-level devices replicate the higher-level API, and should accommodate to -- it. Each device should: -- -- - Upon initialisation, return any necessary information to poll it again. @@ -153,7 +153,7 @@ initializeWiimote = do -- This operation uses the IR for the controller's position, and the main (A) -- button for the click. -- --- TODO: Allow configuring the button and using other motion mechamisms +-- TODO: Allow configuring the button and using other motion mechanisms -- (accelerometers). -- -- TODO: This should be split in two operations. One that presents a nice From c4f08b774dd661183ccce4c6522b476a77d74690 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 190/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/ObjectSF.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ObjectSF.hs b/src/ObjectSF.hs index b8b9947..b730fcc 100644 --- a/src/ObjectSF.hs +++ b/src/ObjectSF.hs @@ -38,7 +38,7 @@ type ObjectSF = SF ObjectInput ObjectOutput -- The reason for depending on 'Objects' is that objects may choose to follow -- other objects. -- --- TODO: Would it be possible to depend on the specific object sfs internally +-- TODO: Would it be possible to depend on the specific object SFs internally -- and remove the explicit 'knownObjects'? I guess so, so long as it's possible -- to always provide the same input to those SFs that they will have in the -- game: because they are different instances, we need the exact same input to From 5a269a751951e2813945cc1095e285d3052e4124 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 191/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/Objects.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Objects.hs b/src/Objects.hs index f568b8a..e605e7f 100644 --- a/src/Objects.hs +++ b/src/Objects.hs @@ -92,7 +92,7 @@ type Collisions = [Collision] -- modified by the collision. -- -- Take into account that the same object could take part in several --- simultaneous collitions, so these velocities should be added (per object). +-- simultaneous collisions, so these velocities should be added (per object). data Collision = Collision { collisionData :: [(ObjectName, Vel2D)] } -- ObjectId x Velocity deriving Show From dab3b49d330087c55edf8995a8f422ae529804c9 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Mon, 3 Apr 2023 00:26:36 +0000 Subject: [PATCH 192/201] Fix typos in comments (KSG Haskell 1.3.0 - 5.8). Refs #103. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid typos in definitions, module names, documentation, and comments. --- src/Physics/TwoDimensions/Physics.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Physics/TwoDimensions/Physics.hs b/src/Physics/TwoDimensions/Physics.hs index 1db34a2..bd69642 100644 --- a/src/Physics/TwoDimensions/Physics.hs +++ b/src/Physics/TwoDimensions/Physics.hs @@ -3,7 +3,7 @@ -- License : See LICENSE file. -- Maintainer : Ivan Perez -- --- A very simple physics subsytem. It currently detects shape overlaps only, +-- A very simple physics subsystem. It currently detects shape overlaps only, -- the actual physics movement is carried out in Yampa itself, as it is very -- simple using integrals and derivatives. module Physics.TwoDimensions.Physics where From 3b8e1e05b4cbc11487a973c70d319ab9c779659c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:59:34 +0000 Subject: [PATCH 193/201] Remove commented code (KSG Haskell 1.3.0 - 5.9). Refs #103. Avoid including commented code, either old or alternative implementations, or ideas. --- src/Constants.hs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Constants.hs b/src/Constants.hs index bed9aca..e430a12 100644 --- a/src/Constants.hs +++ b/src/Constants.hs @@ -77,13 +77,6 @@ velTrans = 0.2 maxVNorm :: Double maxVNorm = 300 --- Delays --- restartDelay :: Time --- restartDelay = 3 --- --- wonDelay :: Time --- wonDelay = 3 - -- * Debugging -- | Initial level. Change this in the code to start From a63069c6e95a19ef8f2fec774239df068158fd6c Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:26:29 +0000 Subject: [PATCH 194/201] Remove commented code (KSG Haskell 1.3.0 - 5.9). Refs #103. Avoid including commented code, either old or alternative implementations, or ideas. --- src/GameCollisions.hs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/GameCollisions.hs b/src/GameCollisions.hs index b294efd..5e3a67c 100644 --- a/src/GameCollisions.hs +++ b/src/GameCollisions.hs @@ -63,28 +63,6 @@ detectCollisions''' m o | fst m == fst o = [] -- Same object -> no collision | otherwise = maybeToList (detectCollision (snd m) (snd o)) --- updateObjPos :: SF (ILKey, Object) (ILKey, Object) --- updateObjPos = proc (i, o) -> do --- -- Since we are saving the position to avoid having to keep the last known --- -- position in memory every time and integrate over a range every time --- -- (would that really happen???) we use an integral over an interval. --- -- I really wonder if this integration thing in Yampa works the way it is --- -- expected to work. Does it work well for non-linear equations? --- -- --- -- Integral only for dt interval --- actualVel <- iterFrom (\_ (v1, v2) dt _ -> (v1 * dt, v2 * dt)) (0, 0) --- -< objectVel o --- --- -- Update position --- let newPos = objectPos o ^+^ actualVel --- o' = o { objectPos = newPos } --- returnA -< (i, o') - --- killBall :: ObjectOutput -> ObjectOutput --- killBall oo = oo { outputObject = o' } --- where o = outputObject oo --- o' = o { objectDead = True} - -- | Return the new velocity as changed by the collection of collisions. -- -- HN 2014-09-07: New interface to collision detection. From 6fffa18a8d8de66e58f9d25b1d8c1e1db0a6277e Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:27:04 +0000 Subject: [PATCH 195/201] Remove commented code (KSG Haskell 1.3.0 - 5.9). Refs #103. Avoid including commented code, either old or alternative implementations, or ideas. --- src/GameState.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/GameState.hs b/src/GameState.hs index 2f30c3f..5d6bb24 100644 --- a/src/GameState.hs +++ b/src/GameState.hs @@ -11,8 +11,6 @@ -- empty. module GameState where --- import FRP.Yampa as Yampa - -- Internal imports import Objects From 2e91414de42da6b2e2267ec197f7d22318624082 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:56:19 +0000 Subject: [PATCH 196/201] Remove commented code (KSG Haskell 1.3.0 - 5.9). Refs #103. Avoid including commented code, either old or alternative implementations, or ideas. --- src/FRP/Extra/Yampa.hs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/FRP/Extra/Yampa.hs b/src/FRP/Extra/Yampa.hs index 3d8b53a..ae604f2 100644 --- a/src/FRP/Extra/Yampa.hs +++ b/src/FRP/Extra/Yampa.hs @@ -10,8 +10,6 @@ module FRP.Extra.Yampa where import Control.Arrow import FRP.Yampa --- Auxiliary Yampa stuff - -- holdWhen behaves normally, outputting only the b, when the second value -- is false, and it holds the last known value when the value is True. holdWhen :: b -> SF a (b, Bool) -> SF a b From 90aafa1f5bdbcb3467efc457d26b587a85bef75d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sun, 2 Apr 2023 23:35:45 +0000 Subject: [PATCH 197/201] Document changes in CHANGELOG. Refs #103. --- CHANGELOG | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index ec91a8a..f150fdc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,9 @@ -2023-04-01 Ivan Perez : +2023-04-02 Ivan Perez : * Bump version bounds of Yampa/bearriver (#104). * Update dist in travis config file to Bionic (#105). * Update GHC versions in travis config file (#106). * Enable CI builds of branches used by our development process (#107). + * Conform to style guide (#103). 2017-11-02 Ivan Perez : * Version bump (0.1.5.4). From ef03599e287e878e1a909b5cfda8c40dd1971d2f Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 8 Apr 2023 21:23:35 +0000 Subject: [PATCH 198/201] Add default-language to executable. Refs #108. Add default-language field to executable. This is necessary in order to bump the cabal-version, which is necessary to release on hackage. --- haskanoid.cabal | 3 +++ 1 file changed, 3 insertions(+) diff --git a/haskanoid.cabal b/haskanoid.cabal index ef46ecc..726b86e 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -110,6 +110,9 @@ executable haskanoid simple-affine-space, transformers >= 0.3 && < 0.6 + default-language: + Haskell2010 + if flag(bearriver) build-depends: bearriver >= 0.9.6 && < 0.15 else From 294635ef992781e92eb75078c39a94ed1b55849b Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 8 Apr 2023 21:24:22 +0000 Subject: [PATCH 199/201] Bump cabal-version. Refs #108. Bump cabal-version to the minimum required to publish on hackage. --- haskanoid.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index 726b86e..3aebdda 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -45,7 +45,7 @@ category: Game, Reactivity, FRP build-type: Simple -- Constraint on the version of Cabal needed to build this package. -cabal-version: >=1.8 +cabal-version: >=1.10 data-files: data/*.png data/*.wav data/*.mp3 data/*.ttf From 275ab7b868acf225d371a9242220a39171c28364 Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 8 Apr 2023 20:46:29 +0000 Subject: [PATCH 200/201] Version bump (0.1.6). Refs #108. We update the comment associated to the version number because it points to a versioning policy that we are not using. We use semver with 3 numbers only. --- haskanoid.cabal | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/haskanoid.cabal b/haskanoid.cabal index 3aebdda..83a2bce 100644 --- a/haskanoid.cabal +++ b/haskanoid.cabal @@ -4,13 +4,11 @@ -- The name of the package. name: haskanoid --- The package version. See the Haskell package versioning policy (PVP) --- for standards guiding when and how versions should be incremented. --- http://www.haskell.org/haskellwiki/Package_versioning_policy +-- The package version. We follow semantic versioning. -- PVP summary: +-+------- breaking API changes --- | | +----- non-breaking API additions --- | | | +--- code changes with no API change -version: 0.1.5.4 +-- | | +----- non-breaking changes +-- | | | +version: 0.1.6 -- A short (one-line) description of the package. synopsis: A breakout game written in Yampa using SDL From e281bb03b1e09ec71d168df9914b39a6e9ff296d Mon Sep 17 00:00:00 2001 From: Ivan Perez Date: Sat, 8 Apr 2023 20:46:55 +0000 Subject: [PATCH 201/201] Document changes in CHANGELOG. Refs #108. Document also changes incorporated in this release that were not included in the CHANGELOG when they were originally merged. --- CHANGELOG | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index f150fdc..425822e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,12 @@ -2023-04-02 Ivan Perez : +2023-04-08 Ivan Perez : + * Version bump (0.1.6) (#108). + * Simplify travis file (#58). + * Update GHC versions, condition, publication in travis (#77). + * Update to support Yampa 0.13 (#82). + * Update pointer to hands-on file (#85). + * Add support for bearriver (#95). + * Support stopping the game with letter q (#99). + * Update installation instructions (#102). * Bump version bounds of Yampa/bearriver (#104). * Update dist in travis config file to Bionic (#105). * Update GHC versions in travis config file (#106).