packages feed

FunGEn 0.4.6.1 → 1.0

raw patch · 8 files changed

+117/−123 lines, 8 filesdep +base-compatdep ~FunGEndep ~GLUTdep ~OpenGLPVP ok

version bump matches the API change (PVP)

Dependencies added: base-compat

Dependency ranges changed: FunGEn, GLUT, OpenGL, base

API changes (from Hackage documentation)

- Graphics.UI.Fungen: alt :: Modifiers -> KeyState
- Graphics.UI.Fungen: ctrl :: Modifiers -> KeyState
- Graphics.UI.Fungen: shift :: Modifiers -> KeyState
- Graphics.UI.GLUT.Input: instance Eq KeyEvent
+ Graphics.UI.Fungen: [alt] :: Modifiers -> KeyState
+ Graphics.UI.Fungen: [ctrl] :: Modifiers -> KeyState
+ Graphics.UI.Fungen: [shift] :: Modifiers -> KeyState
+ Graphics.UI.GLUT.Input: instance GHC.Classes.Eq Graphics.UI.GLUT.Input.KeyEvent
- Graphics.UI.Fungen: type Tile t = (Int, Bool, Float, t)
+ Graphics.UI.Fungen: type Tile t = (Int, Bool, Float, t) index of picture, possibility to move, cost to move, additional params
- Graphics.UI.Fungen: unless :: Monad m => Bool -> m () -> m ()
+ Graphics.UI.Fungen: unless :: (Monad m) => Bool -> m () -> m ()
- Graphics.UI.Fungen: when :: Monad m => Bool -> m () -> m ()
+ Graphics.UI.Fungen: when :: (Monad m) => Bool -> m () -> m ()

Files

CHANGES view
@@ -1,3 +1,9 @@+1.0 2015/9/21++* support GHC 7.10+* support stack+* repo moved to haskell-game organisation+ 0.4.6.1 2014/10/9  * update changelog
FunGEn.cabal view
@@ -1,5 +1,5 @@ name:               FunGEn
-version:            0.4.6.1
+version:            1.0
 copyright:          (C) 2002 Andre Furtado <awbf@cin.ufpe.br>
 license:            BSD3
 license-file:       LICENSE
@@ -20,20 +20,26 @@ 
     * Initialization, updating, removing, rendering and grouping
       routines for game objects
+
     * Definition of a game background (or map), including texture-based
       maps and tile maps
+
     * Reading and intepretation of the player's keyboard and mouse input
+
     * Collision detection
+
     * Time-based functions and pre-defined game actions
+
     * Loading and displaying of 24-bit bitmap files
+
     * Some debugging and game performance evaluation facilities
 
     This package receives only basic maintenance (see home page).
 
-stability:          alpha
+stability:          beta
 cabal-version:      >= 1.8
 build-type:         Simple
-tested-with:        GHC==7.8.2
+tested-with:        GHC==7.8.4, GHC==7.10.2
 extra-source-files: 
                     README.md,
                     CHANGES
@@ -43,7 +49,7 @@ 
 source-repository head
   type:     git
-  location: https://github.com/simonmichael/fungen
+  location: https://github.com/haskell-game/fungen
 
 library
   ghc-options:      -W
@@ -63,9 +69,10 @@                     Graphics.UI.GLUT.Input
 
   build-depends:
-                    base   == 4.*
-                   ,OpenGL == 2.9.*
-                   ,GLUT   == 2.5.*
+                    base == 4.*
+                   ,base-compat
+                   ,OpenGL <= 2.14
+                   ,GLUT <= 2.8
                    ,random
 
 executable fungen-hello
Graphics/UI/Fungen/Display.hs view
@@ -37,7 +37,7 @@ displayIOGame gameCycle = do
         (_,_,objectsMoving) <- getGameFlags
         when objectsMoving moveAllObjects
-	gameCycle
+        gameCycle
         (mapDrawing,objectsDrawing,_) <- getGameFlags
         when mapDrawing drawMap
         when objectsDrawing drawAllObjects
Graphics/UI/Fungen/Game.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-}
 {-# OPTIONS_HADDOCK hide #-}
 {- | 
 This FunGEn module contains some important game routines.
@@ -64,7 +65,9 @@ import Graphics.UI.Fungen.Objects
 import Graphics.Rendering.OpenGL
 import Graphics.UI.GLUT
+#if !MIN_VERSION_base(4,8,0)
 import Control.Applicative (Applicative(..))
+#endif
 import Control.Monad
 import Data.IORef
 import Text.Printf
@@ -113,17 +116,17 @@ -- * @fpsInfo       :: IORef (Int,Int,Float)     -- only for debugging@
 -- 
 data Game t s u v = Game {
-	gameMap       :: IORef (GameMap v), -- ^ a map (background)
-    	gameState     :: IORef u,           -- ^ initial game state
-	gameFlags     :: IORef GameFlags,   -- ^ initial game flags
-	objManagers   :: IORef [(ObjectManager s)], -- ^ some object managers
-	textList      :: IORef [Text],              -- ^ some texts
-	quadricObj    :: QuadricPrimitive,          -- ^ a quadric thing
-	windowConfig  :: IORef WindowConfig,        -- ^ a config for the main window
-	gameAttribute :: IORef t,                   -- ^ a game attribute
-	pictureList   :: IORef [TextureObject],     -- ^ some pictures
-	fpsInfo       :: IORef (Int,Int,Float)  -- only for debugging
-	}
+        gameMap       :: IORef (GameMap v), -- ^ a map (background)
+        gameState     :: IORef u,           -- ^ initial game state
+        gameFlags     :: IORef GameFlags,   -- ^ initial game flags
+        objManagers   :: IORef [(ObjectManager s)], -- ^ some object managers
+        textList      :: IORef [Text],              -- ^ some texts
+        quadricObj    :: QuadricPrimitive,          -- ^ a quadric thing
+        windowConfig  :: IORef WindowConfig,        -- ^ a config for the main window
+        gameAttribute :: IORef t,                   -- ^ a game attribute
+        pictureList   :: IORef [TextureObject],     -- ^ some pictures
+        fpsInfo       :: IORef (Int,Int,Float)  -- only for debugging
+        }
 
 -- | IOGame is the monad in which game actions run. An IOGame action
 -- takes a Game (with type parameters @t s u v@), performs some IO,
@@ -269,7 +272,7 @@             windowConfig  = gW,
             gameAttribute = gA,
             pictureList   = gP,
-            fpsInfo 	  = gFPS
+            fpsInfo       = gFPS
             })
 
 -- | loads all of the pictures used in the game
@@ -419,17 +422,17 @@ -- | adds an object to a previously created group
 addObjectsToGroup :: [(GameObject s)] -> String -> IOGame t s u v ()
 addObjectsToGroup objs managerName = do
-	-- manager <- findObjectManager managerName
-	managers <- getObjectManagers
-	let newManagers = addObjectsToManager objs managerName managers 
-	setObjectManagers newManagers
+        -- manager <- findObjectManager managerName
+        managers <- getObjectManagers
+        let newManagers = addObjectsToManager objs managerName managers 
+        setObjectManagers newManagers
 
 -- | adds an object to a new group
 addObjectsToNewGroup :: [(GameObject s)] -> String -> IOGame t s u v ()
 addObjectsToNewGroup objs newMngName = do
-	let newManager = objectGroup newMngName objs
-	managers <- getObjectManagers
-	setObjectManagers (newManager:managers)
+        let newManager = objectGroup newMngName objs
+        managers <- getObjectManagers
+        setObjectManagers (newManager:managers)
 
 -- | returns an object manager of the game, given its name (internal use)
 findObjectManager :: String -> IOGame t s u v (ObjectManager s)
@@ -506,8 +509,8 @@ -- | changes the current picture of a multitextured object
 setObjectCurrentPicture :: Int -> GameObject s -> IOGame t s u v ()
 setObjectCurrentPicture n obj = do
-	picList <- getPictureList
-	replaceObject obj (updateObjectPicture n ((length picList) - 1))
+        picList <- getPictureList
+        replaceObject obj (updateObjectPicture n ((length picList) - 1))
 
 -- | changes the attribute of an object, given its new attribute
 setObjectAttribute :: s -> GameObject s -> IOGame t s u v ()
@@ -757,15 +760,15 @@ -- | shows the frame rate (or frame per seconds) 
 showFPS :: BitmapFont -> (GLdouble,GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
 showFPS font pos r g b = do
-	(framei,timebasei,fps) <- getFpsInfo
-	timei <- getElapsedTime
-	let frame = (toEnum (framei + 1)) :: Float
-	    timebase = (toEnum timebasei) :: Float
-	    time = (toEnum timei) :: Float
-	if (timei - timebasei > 1000)
-		then setFpsInfo (0,timei,(frame*(toEnum 1000)/(time-timebase)))
-		else setFpsInfo ((framei + 1),timebasei,fps)
-	printOnScreen (printf "%.1f" fps) font pos r g b
+        (framei,timebasei,fps) <- getFpsInfo
+        timei <- getElapsedTime
+        let frame = (toEnum (framei + 1)) :: Float
+            timebase = (toEnum timebasei) :: Float
+            time = (toEnum timei) :: Float
+        if (timei - timebasei > 1000)
+                then setFpsInfo (0,timei,(frame*(toEnum 1000)/(time-timebase)))
+                else setFpsInfo ((framei + 1),timebasei,fps)
+        printOnScreen (printf "%.1f" fps) font pos r g b
 
 -- | get the elapsed time of the game
 getElapsedTime :: IOGame t s u v Int
@@ -774,16 +777,16 @@ -- | delay for N  seconds while continuing essential game functions
 wait :: Int -> IOGame t s u v ()
 wait delay = do
-	printText 				    -- force text messages to be printed (is not working properly!)
-	(framei,timebasei,fps) <- getFpsInfo
-	setFpsInfo (framei,(timebasei + delay),fps) -- helps FPS info to be displayed correctly (if requested)
-	startTime <- getElapsedTime
-	
-	waitAux delay startTime
+        printText                                   -- force text messages to be printed (is not working properly!)
+        (framei,timebasei,fps) <- getFpsInfo
+        setFpsInfo (framei,(timebasei + delay),fps) -- helps FPS info to be displayed correctly (if requested)
+        startTime <- getElapsedTime
+        
+        waitAux delay startTime
 
 waitAux :: Int -> Int -> IOGame t s u v ()
 waitAux delay startTime = do
-	presentTime <- getElapsedTime
-	if (presentTime - startTime > delay)
-		then return ()
-		else waitAux delay startTime
+        presentTime <- getElapsedTime
+        if (presentTime - startTime > delay)
+                then return ()
+                else waitAux delay startTime
Graphics/UI/Fungen/Map.hs view
@@ -116,7 +116,7 @@ 
 updateCurrentIndex :: GameMap t -> Int -> GameMap t
 updateCurrentIndex (MultiMap mapList _) i | (i >= (length mapList)) = error "Map.updateMultiMapIndex error: map index out of range!"
-					  | otherwise = (MultiMap mapList i)
+                                          | otherwise = (MultiMap mapList i)
 updateCurrentIndex _ _ = error "Map.updateCurrentIndex error: the game map is not a MultiMap!"
 
 -----------------------------
@@ -142,14 +142,14 @@ multiMap :: [(GameMap t)] -> Int -> GameMap t
 multiMap [] _ = error "Map.multiMap  error: the MultiMap map list should not be empty!"
 multiMap mapList currentMap | (currentMap >= (length mapList)) = error "Map.multiMap error: map index out of range!"
-			    | (mapListContainsMultiMap mapList) = error "Map.multiMap error: a MultiMap should not contain another MultiMap!"
-			    | otherwise = MultiMap mapList currentMap
+                            | (mapListContainsMultiMap mapList) = error "Map.multiMap error: a MultiMap should not contain another MultiMap!"
+                            | otherwise = MultiMap mapList currentMap
 
 -- checks if a GameMap list contains a multimap (internal use only!)
 mapListContainsMultiMap :: [(GameMap t)] -> Bool
 mapListContainsMultiMap [] = False
 mapListContainsMultiMap (a:as) | (isMultiMap a) = True
-			       | otherwise = mapListContainsMultiMap as
+                               | otherwise = mapListContainsMultiMap as
 
 -- checks if the tile matrix is a square matrix
 matrixOk :: TileMatrix t -> Bool
Graphics/UI/Fungen/Objects.hs view
@@ -44,7 +44,7 @@ import Graphics.Rendering.OpenGL hiding (Primitive)
 
 data GameObject t = GO {
-    objId	   :: Integer,
+    objId          :: Integer,
     objName        :: String,
     objManagerName :: String,
     objPicture     :: GameObjectPicture,
@@ -56,9 +56,9 @@     }
 
 data ObjectManager t = OM {
-    mngName    :: String,		-- name of the manager
-    mngCounter :: Integer,		-- next current avaible index for a new object
-    mngObjects :: [(GameObject t)]	-- the SET of objects
+    mngName    :: String,               -- name of the manager
+    mngCounter :: Integer,              -- next current avaible index for a new object
+    mngObjects :: [(GameObject t)]      -- the SET of objects
     }
 
 data GamePrimitive
@@ -163,17 +163,17 @@ ----------------------------------------
 object :: String -> ObjectPicture -> Bool -> (GLdouble,GLdouble) -> (GLdouble,GLdouble) -> t -> GameObject t
 object name pic asleep pos speed oAttrib = let (picture, size) = createPicture pic in
-			GO {
-			objId          = 0,
-			objName        = name,
-			objManagerName = "object not grouped yet!",
-			objPicture     = picture,
-			objAsleep      = asleep,
-			objSize        = size,
-			objPosition    = pos,
-			objSpeed       = speed,
-			objAttribute   = oAttrib
-			}
+                        GO {
+                        objId          = 0,
+                        objName        = name,
+                        objManagerName = "object not grouped yet!",
+                        objPicture     = picture,
+                        objAsleep      = asleep,
+                        objSize        = size,
+                        objPosition    = pos,
+                        objSpeed       = speed,
+                        objAttribute   = oAttrib
+                        }
 
 createPicture :: ObjectPicture -> (GameObjectPicture,Point2D)
 createPicture (Basic (Polyg points r g b fillMode))  = (B (P (point2DtoVertex3 points) (Color4 r g b 1.0) fillMode),findSize points)
@@ -200,13 +200,13 @@ addObjectsToManager :: [(GameObject t)] -> String -> [(ObjectManager t)] -> [(ObjectManager t)]
 addObjectsToManager _ managerName [] = error ("Objects.addObjectsToManager error: object manager " ++ managerName ++ " does not exists!")
 addObjectsToManager objs managerName (m:ms) | (getObjectManagerName m == managerName) = (addObjectsToManagerAux objs m):ms
-					    | otherwise = m:(addObjectsToManager objs managerName ms)
+                                            | otherwise = m:(addObjectsToManager objs managerName ms)
 
 
 addObjectsToManagerAux :: [(GameObject t)] -> ObjectManager t -> ObjectManager t
 addObjectsToManagerAux objs mng = let counter = getObjectManagerCounter mng
-				      newObjects = adjustNewObjects objs (getObjectManagerCounter mng) (getObjectManagerName mng)
-				  in mng {mngObjects = newObjects ++ (getObjectManagerObjects mng), mngCounter = counter + (toEnum (length objs))}
+                                      newObjects = adjustNewObjects objs (getObjectManagerCounter mng) (getObjectManagerName mng)
+                                  in mng {mngObjects = newObjects ++ (getObjectManagerObjects mng), mngCounter = counter + (toEnum (length objs))}
 
 adjustNewObjects :: [(GameObject t)] -> Integer -> String -> [(GameObject t)]
 adjustNewObjects [] _ _ = []
@@ -267,12 +267,12 @@ findObjectFromIdAux :: Integer -> String ->  [(ObjectManager t)] -> GameObject t
 findObjectFromIdAux _ managerName [] = error ("Objects.findObjectFromIdAux error: object group " ++ managerName ++ " not found!")
 findObjectFromIdAux objectId managerName (m:ms) | (managerName == getObjectManagerName m) = searchFromId objectId (getObjectManagerObjects m)
-                     				| otherwise = findObjectFromIdAux objectId managerName ms
+                                                | otherwise = findObjectFromIdAux objectId managerName ms
 
 searchFromId :: Integer -> [(GameObject t)] -> GameObject t
 searchFromId _ [] = error ("Objects.searchFromId error: object not found!")
 searchFromId objectId (o:os) | (objectId == getGameObjectId o) = o
-			     | otherwise = searchFromId objectId os
+                             | otherwise = searchFromId objectId os
 
 
 searchObjectManager :: String -> [(ObjectManager t)] -> ObjectManager t
@@ -298,7 +298,7 @@ updateObject _ _ managerName [] = error ("Objects.updateObject error: object manager: " ++ managerName ++ " not found!")
 updateObject f objectId managerName (m:ms) | (getObjectManagerName m == managerName) = (updateObjectManagerObjects newObjects m):ms
                                            | otherwise = m:(updateObject f objectId managerName ms)
-                        		   where newObjects = updateObjectAux f objectId (getObjectManagerObjects m)
+                                           where newObjects = updateObjectAux f objectId (getObjectManagerObjects m)
 
 updateObjectAux :: (GameObject t -> GameObject t) -> Integer -> [(GameObject t)] -> [(GameObject t)]
 updateObjectAux _ _ [] = error ("Objects.updateObjectAux error: object not found!")
Graphics/UI/Fungen/Text.hs view
@@ -2,7 +2,7 @@ {- | 
 This FunGEn module contains some functions to print text on the screen.
 Fonts supported: Bitmap9By15, Bitmap8By13, BitmapTimesRoman10, BitmapTimesRoman24
-		 BitmapHelvetica10, BitmapHelvetica12, BitmapHelvetica18
+BitmapHelvetica10, BitmapHelvetica12, BitmapHelvetica18
 -}
 {- 
 
@@ -17,9 +17,9 @@ -}
 
 module Graphics.UI.Fungen.Text (
-	BitmapFont(..),
-	Text,
-	putGameText
+        BitmapFont(..),
+        Text,
+        putGameText
 ) where
 
 import Graphics.UI.GLUT
@@ -32,8 +32,8 @@ putGameText :: [Text] -> IO ()
 putGameText [] = return ()
 putGameText ((text,font,(x,y),r,g,b):ts) = do
-	loadIdentity
-	color (Color3 r g b)
-	rasterPos (Vertex2 x y)
-	renderString font text
-	putGameText ts
+        loadIdentity
+        color (Color3 r g b)
+        rasterPos (Vertex2 x y)
+        renderString font text
+        putGameText ts
README.md view
@@ -46,25 +46,23 @@ * Some debugging and game performance evaluation facilities <!-- * Sound support (windows only, not in current release) --> -I ([Simon Michael](http://joyful.com)) provide basic maintenance for-this package. If you'd like to take it and run with it, or-co-maintain, contact me. I'm `sm` on the #haskell-game IRC channel.-On 2014/10/9 I moved it from darcs hub to github.+[Simon Michael](http://joyful.com) provides basic maintenance for+this package. If you'd like to take it over, contact me (`sm` on the #haskell-game IRC channel).  **Home:**      <http://joyful.com/fungen> \ **Hackage:**   <http://hackage.haskell.org/package/FunGEn> \-**Changelog:** <http://hackage.haskell.org/package/FunGEn/changelog> \-**Code:**      <https://github.com/simonmichael/fungen> \+**Code:**      <https://github.com/haskell-game/fungen> \ \ **Docs:**\-&nbsp; (Latest available) [API docs](http://hackage.haskell.org/packages/archive/FunGEn/0.4.2/doc/html/Graphics-UI-Fungen.html) \+&nbsp; [Changelog](http://hackage.haskell.org/package/FunGEn/changelog) \+&nbsp; [API docs](http://hackage.haskell.org/packages/archive/FunGEn/0.4.6.1/doc/html/Graphics-UI-Fungen.html) \ &nbsp; Andre's original [pong tutorial](site/example.html) \ &nbsp; Haskell wiki [Game_Development](http://www.haskell.org/haskellwiki/Game_Development) \ &nbsp; Haskell wiki [OpenGL tutorial](http://www.haskell.org/haskellwiki/OpenGLTutorial1) \ <!-- Updated [pong tutorial](TUTORIAL.html) \ --> <!-- the [old site](http://www.cin.ufpe.br/~haskell/fungen) \ --> \-**Discussion & help:**\+**Community:**\ &nbsp; [#haskell-game](http://ircbrowse.net/day/haskell-game/today/recent) IRC channel        ([join](http://webchat.freenode.net/?channels=haskell-game)) \ &nbsp; [FunGEn questions](http://stackoverflow.com/search?tab=newest&q=fungen) on Stack Overflow \@@ -73,34 +71,27 @@   ## Getting started--**Install from hackage, run the examples:**- ``` $ cabal update $ [cabal sandbox init]    # if needed, to avoid dependency problems-$ cabal install FunGEn-$ fungen-hello            # make sure ~/.cabal/bin or ./.cabal-sandbox/bin are in your PATH+$ cabal install FunGEn    # & make sure ~/.cabal/bin or ./.cabal-sandbox/bin or windows equiv. are in your PATH+$ fungen-hello $ fungen-pong $ fungen-worms ```--**Contribute patches:**+or ```-(Fork https://github.com/simonmichael/fungen)-$ git clone https://github.com/MYUSERNAME/fungen.git+$ git clone http://github.com/haskell-game/fungen $ cd fungen-$ cabal sandbox init         # if needed, to avoid dependency problems-$ cabal install              # install library and examples' data files-(Edit examples/pong/pong.hs)-$ cabal build fungen-pong && dist/build/fungen-pong/fungen-pong-(Commit, push, send pull requests)-```-+$ stack install+$ fungen-hello+$ fungen-pong+$ fungen-worms+`````` ----+## History -## FAQ+Andre's 2002 site included this Q & A:  **What is a game engine?** @@ -131,11 +122,7 @@ language) when programming in Haskell. You can find more info on HOpenGL in my HOpenGL Tutorial site, or in its official site. ------## To do--Andre's 2002 site included this message:+and this:  > Current Status: Some feedback indicated that the first version of FunGEn was not as "functional" as it was desired: some game issues were still being dealt through an imperative fashion. This way, the authors of this project decided to change the game engine philosophy: programmers should describe a game as a set of "specifications" rather than defining its behavior imperatively. One plausible alternative for accomplishing this task > is porting the Clean Game Library (CGL) to Haskell, adding some FunGEn specific features. Hence, this is the actual status of the FunGEn project: it is being rebuilt in order to provide game programming mechanisms following the CGL@@ -163,14 +150,7 @@ > Would you like to suggest a feature? Feel free to do it. Would you like to > implement a feature? Please do it! Keep in touch. -and this [old windows code with sound support](/site/FunGEn0.1-Win32.zip).--------## Credits--Andre's 2002 credits:+and these credits:  > FunGEn was created by Andre Furtado, Computation Science graduation > student at the Informatics Center (CIn) of the Federal University of@@ -194,5 +174,3 @@ > or FITNESS FOR A PARTICULAR PURPOSE. I would thank you if you cite my name > and this site if you are going to use FunGEn for other things besides home > programming.-----