Skip to content

Commit

Permalink
Merge branch 'release-0.1.6'. Refs #108.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanperez-keera committed Apr 8, 2023
2 parents 4b17935 + e281bb0 commit 8b15f40
Show file tree
Hide file tree
Showing 30 changed files with 1,279 additions and 980 deletions.
42 changes: 23 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
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: c
env:
- GHCVER=7.6.3
- GHCVER=7.8.4
- GHCVER=7.10.3
- GHCVER=8.0.1
- CABALVER=2.4 GHCVER=8.2.2
- CABALVER=2.4 GHCVER=8.4.4
- 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

# Note: the distinction between `before_install` and `install` is not important.
before_install:
- unset CC
- travis_retry sudo add-apt-repository -y ppa:hvr/ghc
- travis_retry sudo apt-get update
- 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 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
- 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

notifications:
email: true
- travis_retry cabal configure -f-wiimote -f-kinect --enable-tests && cabal build && cabal test

branches:
only:
- master
- develop
- /^develop.*/
- /^hotfix.*/
- /^release.*/

deploy:
provider: hackage
Expand All @@ -37,4 +41,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.4.4
15 changes: 15 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2023-04-08 Ivan Perez <[email protected]>:
* 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).
* Enable CI builds of branches used by our development process (#107).
* Conform to style guide (#103).

2017-11-02 Ivan Perez <[email protected]>:
* Version bump (0.1.5.4).
* Adds new levels.
Expand Down
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -102,16 +100,23 @@ 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
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.

Expand All @@ -129,7 +134,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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 21 additions & 11 deletions haskanoid.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -45,7 +43,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

Expand All @@ -57,6 +55,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
Expand Down Expand Up @@ -99,12 +101,20 @@ 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

default-language:
Haskell2010

if flag(bearriver)
build-depends: bearriver >= 0.9.6 && < 0.15
else
build-depends: Yampa >= 0.13 && < 0.15

if flag(wiimote)
build-depends: hcwiid
Expand Down
47 changes: 27 additions & 20 deletions src/Audio.hs
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
-- | A layer of abstraction on top of SDL audio.
-- |
-- Copyright : (c) Keera Studios, 2010-2014.
-- License : See LICENSE file.
-- Maintainer : Ivan Perez <[email protected]>
--
-- 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(..),
initAudio,
loadAudio,
loadMusic,
playMusic,
playFile,
stopMusic,
musicPlaying) where
( Music(..)
, Audio(..)
, initAudio
, loadAudio
, loadMusic
, playMusic
, playFile
, stopMusic
, musicPlaying
)
where

import Control.Applicative ((<$>))
import Control.Monad
import Control.Concurrent
import qualified Graphics.UI.SDL.Mixer.General as SDL.Mixer
-- External imports
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.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.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 }

data Audio = Audio { audioName :: String, unAudio :: SDL.Mixer.Types.Chunk }

-- | Initialize the audio subsystem.
Expand Down Expand Up @@ -63,6 +70,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)
46 changes: 29 additions & 17 deletions src/Constants.hs
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
-- |
-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014.
-- License : See LICENSE file.
-- Maintainer : Ivan Perez <[email protected]>
--
-- Game constants.
module Constants where

-- External imports
import FRP.Yampa

-- Internal imports
import Physics.TwoDimensions.Dimensions

width :: Double
width = 640
width = 640

height :: Double
height = 600

gameTop :: Double
gameTop = 100
gameLeft :: Double
gameLeft = 0
gameTop :: Double
gameTop = 100

gameLeft :: Double
gameLeft = 0

gameWidth :: Double
gameWidth = width

gameHeight :: Double
gameHeight = height - gameTop

Expand All @@ -24,20 +36,27 @@ loadingDelay = 2 -- seconds
paddleWidth, paddleHeight :: Double
paddleWidth = 104
paddleHeight = 24

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

maxBlockLife :: Int
maxBlockLife = 3

minBlockLife :: Int
minBlockLife = 1

Expand All @@ -57,13 +76,6 @@ velTrans = 0.2
-- Max speed
maxVNorm :: Double
maxVNorm = 300

-- Delays
-- restartDelay :: Time
-- restartDelay = 3
--
-- wonDelay :: Time
-- wonDelay = 3

-- * Debugging

Expand Down
29 changes: 19 additions & 10 deletions src/Control/Extra/Monad.hs
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
-- |
-- Copyright : (c) Ivan Perez & Henrik Nilsson, 2014.
-- License : See LICENSE file.
-- Maintainer : Ivan Perez <[email protected]>
--
-- 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 ()
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
Loading

0 comments on commit 8b15f40

Please sign in to comment.