-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A lightweight, cross-platform, OpenGL-based game engine.
--
-- FunGEn (Functional Game Engine) is a BSD-licensed, cross-platform,
-- OpenGL-based, non-FRP game engine written in Haskell. Created by Andre
-- Furtado in 2002, it's the oldest Haskell game engine, and with very
-- few dependencies and two example games, it's one of the easiest ways
-- to get started with Haskell game development.
--
-- The FunGEn library provides:
--
--
-- - 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).
@package FunGEn
@version 1.1
-- | GLUT-based keyboard/mouse handling.
--
-- Sven Panne 2000 Sven.Panne@informatik.uni-muenchen.de
--
-- This provides a "still down" event in addition to GLUT's key/mouse
-- button up/down events, and manages bindings from input events to
-- actions.
module Graphics.UI.GLUT.Input
-- | A generalized view of keys
data Key
Char :: Char -> Key
SpecialKey :: SpecialKey -> Key
MouseButton :: MouseButton -> Key
data KeyEvent
Press :: KeyEvent
StillDown :: KeyEvent
Release :: KeyEvent
type KeyBinder = Key -> KeyEvent -> Maybe InputHandler -> IO ()
type InputHandler = Modifiers -> Position -> IO ()
type StillDownHandler = IO ()
-- | Initialise the input system, which keeps a list of input event to
-- action bindings and executes the the proper actions automatically.
-- Returns a function for adding bindings, and another which should be
-- called periodically (eg from refresh) to trigger still-down actions.
glutInitInput :: IO (KeyBinder, StillDownHandler)
instance GHC.Classes.Eq Graphics.UI.GLUT.Input.KeyEvent
-- | This is the main module of FunGEN (Functional Game Engine), which
-- re-exports the rest.
module Graphics.UI.Fungen
-- | Configure a FunGEn game and start it running.
funInit :: WindowConfig -> GameMap v -> [ObjectManager s] -> u -> t -> [InputBinding t s u v] -> IOGame t s u v () -> RefreshType -> FilePictureList -> IO ()
-- | Exit the program successfully (from within a game action).
funExit :: IOGame t s u v ()
-- | position, size and name of the window
type WindowConfig = ((Int, Int), (Int, Int), String)
-- | a bidimensional point in space
type Point2D = (GLdouble, GLdouble)
-- | color in RGB format
type ColorList3 = [(GLubyte, GLubyte, GLubyte)]
-- | width, height and data of bitmap
type AwbfBitmap = (GLsizei, GLsizei, PixelData GLubyte)
-- | invisible colors (in RGB) of bitmap
type InvList = Maybe [(Int, Int, Int)]
-- | Loads a bitmap from a file.
loadBitmap :: FilePath -> Maybe ColorList3 -> IO AwbfBitmap
-- | Loads n bitmaps from n files.
loadBitmapList :: [(FilePath, Maybe ColorList3)] -> IO [AwbfBitmap]
type FilePictureList = [(FilePath, InvList)]
-- | The bitmap fonts available in GLUT. The exact bitmap to be used is
-- defined by the standard X glyph bitmaps for the X font with the given
-- name.
data BitmapFont
-- | A fixed width font with every character fitting in an 8 by 13 pixel
-- rectangle.
-- (-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1)
Fixed8By13 :: BitmapFont
-- | A fixed width font with every character fitting in an 9 by 15 pixel
-- rectangle.
-- (-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1)
Fixed9By15 :: BitmapFont
-- | A 10-point proportional spaced Times Roman font.
-- (-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1)
TimesRoman10 :: BitmapFont
-- | A 24-point proportional spaced Times Roman font.
-- (-adobe-times-medium-r-normal--24-240-75-75-p-124-iso8859-1)
TimesRoman24 :: BitmapFont
-- | A 10-point proportional spaced Helvetica font.
-- (-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1)
Helvetica10 :: BitmapFont
-- | A 12-point proportional spaced Helvetica font.
-- (-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1)
Helvetica12 :: BitmapFont
-- | A 18-point proportional spaced Helvetica font.
-- (-adobe-helvetica-medium-r-normal--18-180-75-75-p-98-iso8859-1)
Helvetica18 :: BitmapFont
-- | String to be printed, font, screen position, color RGB.
type Text = (String, BitmapFont, Point2D, GLclampf, GLclampf, GLclampf)
-- | Display these texts on screen.
putGameText :: [Text] -> IO ()
-- | A game background (flat color, scrollable texture, or tile map), or
-- several of them.
data GameMap t
type Tile t = (Int, Bool, Float, t) " index of picture, possibility to move, cost to move, additional params
"
type TileMatrix t = [[(Tile t)]]
-- | creates a PreColorMap
colorMap :: GLclampf -> GLclampf -> GLclampf -> GLdouble -> GLdouble -> GameMap t
-- | creates a PreTextureMap
textureMap :: Int -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GameMap t
-- | creates a PreTileMap, cheking if the tileMatrix given is valid and
-- automatically defining the map size
tileMap :: TileMatrix t -> GLdouble -> GLdouble -> GameMap t
-- | creates a multimap
multiMap :: [GameMap t] -> Int -> GameMap t
isTileMap :: GameMap t -> Bool
isMultiMap :: GameMap t -> Bool
getMapSize :: GameMap t -> Point2D
getTileMapTileMatrix :: GameMap t -> TileMatrix t
getTileMapScroll :: GameMap t -> Point2D
getTileMapSize :: GameMap t -> Point2D
getTileMapTileSize :: GameMap t -> Point2D
getTilePictureIndex :: Tile t -> Int
getTileBlocked :: Tile t -> Bool
getTileMoveCost :: Tile t -> Float
getTileSpecialAttribute :: Tile t -> t
getCurrentMap :: GameMap t -> GameMap t
updateCurrentMap :: GameMap t -> GameMap t -> GameMap t
updateCurrentIndex :: GameMap t -> Int -> GameMap t
-- | draw the background map
drawGameMap :: GameMap t -> Point2D -> [TextureObject] -> IO ()
-- | clear the screen
clearGameScreen :: GLclampf -> GLclampf -> GLclampf -> IO ()
data ObjectManager t
data GameObject t
data ObjectPicture
Tex :: (GLdouble, GLdouble) -> Int -> ObjectPicture
Basic :: Primitive -> ObjectPicture
data Primitive
Polyg :: [Point2D] -> GLfloat -> GLfloat -> GLfloat -> FillMode -> Primitive
Circle :: GLdouble -> GLfloat -> GLfloat -> GLfloat -> FillMode -> Primitive
data FillMode
Filled :: FillMode
Unfilled :: FillMode
object :: String -> ObjectPicture -> Bool -> (GLdouble, GLdouble) -> (GLdouble, GLdouble) -> t -> GameObject t
getGameObjectId :: GameObject t -> Integer
getGameObjectName :: GameObject t -> String
getGameObjectManagerName :: GameObject t -> String
getGameObjectAsleep :: GameObject t -> Bool
getGameObjectPosition :: GameObject t -> (GLdouble, GLdouble)
getGameObjectSize :: GameObject t -> (GLdouble, GLdouble)
getGameObjectSpeed :: GameObject t -> (GLdouble, GLdouble)
getGameObjectAttribute :: GameObject t -> t
updateObject :: (GameObject t -> GameObject t) -> Integer -> String -> [ObjectManager t] -> [ObjectManager t]
updateObjectAsleep :: Bool -> GameObject t -> GameObject t
updateObjectSize :: (GLdouble, GLdouble) -> GameObject t -> GameObject t
updateObjectPosition :: (GLdouble, GLdouble) -> GameObject t -> GameObject t
updateObjectSpeed :: (GLdouble, GLdouble) -> GameObject t -> GameObject t
updateObjectAttribute :: t -> GameObject t -> GameObject t
updateObjectPicture :: Int -> Int -> GameObject t -> GameObject t
drawGameObjects :: [ObjectManager t] -> QuadricPrimitive -> [TextureObject] -> IO ()
drawGameObject :: GameObject t -> QuadricPrimitive -> [TextureObject] -> IO ()
moveGameObjects :: [ObjectManager t] -> [ObjectManager t]
destroyGameObject :: String -> String -> [ObjectManager t] -> [ObjectManager t]
objectGroup :: String -> [GameObject t] -> ObjectManager t
addObjectsToManager :: [GameObject t] -> String -> [ObjectManager t] -> [ObjectManager t]
getObjectManagerName :: ObjectManager t -> String
getObjectManagerCounter :: ObjectManager t -> Integer
getObjectManagerObjects :: ObjectManager t -> [GameObject t]
findObjectFromId :: GameObject t -> [ObjectManager t] -> GameObject t
searchObjectManager :: String -> [ObjectManager t] -> ObjectManager t
searchGameObject :: String -> ObjectManager t -> GameObject t
-- | A mapping from an input event to an input handler.
type InputBinding t s u v = (Key, KeyEvent, InputHandler t s u v)
-- | A FunGEn input handler is like an IOGame (game action) that takes two
-- extra arguments: the current keyboard modifiers state, and the current
-- mouse position. (For a StillDown event, these will be the original
-- state and position from the Press event.)
type InputHandler t s u v = Modifiers -> Position -> IOGame t s u v ()
data KeyEvent
Press :: KeyEvent
StillDown :: KeyEvent
Release :: KeyEvent
-- | A generalized view of keys
data Key
Char :: Char -> Key
SpecialKey :: SpecialKey -> Key
MouseButton :: MouseButton -> Key
-- | Special keys
data SpecialKey
KeyF1 :: SpecialKey
KeyF2 :: SpecialKey
KeyF3 :: SpecialKey
KeyF4 :: SpecialKey
KeyF5 :: SpecialKey
KeyF6 :: SpecialKey
KeyF7 :: SpecialKey
KeyF8 :: SpecialKey
KeyF9 :: SpecialKey
KeyF10 :: SpecialKey
KeyF11 :: SpecialKey
KeyF12 :: SpecialKey
KeyLeft :: SpecialKey
KeyUp :: SpecialKey
KeyRight :: SpecialKey
KeyDown :: SpecialKey
KeyPageUp :: SpecialKey
KeyPageDown :: SpecialKey
KeyHome :: SpecialKey
KeyEnd :: SpecialKey
KeyInsert :: SpecialKey
KeyNumLock :: SpecialKey
KeyBegin :: SpecialKey
KeyDelete :: SpecialKey
KeyShiftL :: SpecialKey
KeyShiftR :: SpecialKey
KeyCtrlL :: SpecialKey
KeyCtrlR :: SpecialKey
KeyAltL :: SpecialKey
KeyAltR :: SpecialKey
-- | You should actually never encounter this value, it is just here as a
-- safeguard against future changes in the native GLUT library.
KeyUnknown :: Int -> SpecialKey
-- | Mouse buttons, including a wheel
data MouseButton
LeftButton :: MouseButton
MiddleButton :: MouseButton
RightButton :: MouseButton
WheelUp :: MouseButton
WheelDown :: MouseButton
AdditionalButton :: Int -> MouseButton
-- | The state of the keyboard modifiers
data Modifiers
Modifiers :: KeyState -> KeyState -> KeyState -> Modifiers
[shift] :: Modifiers -> KeyState
[ctrl] :: Modifiers -> KeyState
[alt] :: Modifiers -> KeyState
-- | A 2-dimensional position, measured in pixels.
data Position
Position :: !GLint -> !GLint -> Position
-- | Initialise the input system, which keeps a list of input event to
-- action bindings and executes the the proper actions automatically.
-- Returns a function for adding bindings (GLUT's - should return the
-- FunGEn-aware one instead ?), and another which should be called
-- periodically (eg from refresh) to trigger still-down actions.
funInitInput :: [InputBinding t s u v] -> Game t s u v -> IO (KeyBinder, StillDownHandler)
-- | Used by funInit to configure the main loop's timing strategy.
data RefreshType
Idle :: RefreshType
Timer :: Int -> RefreshType
-- | Change the current timing strategy.
setRefresh :: RefreshType -> StillDownHandler -> IO ()
-- | A game has the type Game t s u v, where
--
--
-- - t is the type of the game special attributes
-- - s is the type of the object special attributes
-- - u is the type of the game levels (state)
-- - v is the type of the map tile special attribute, in case we use a
-- Tile Map as the background of our game
--
--
-- For a mnemonic, uh...
--
--
-- - t - Top-level game attribute type,
-- - s - Sprite object attribute type,
-- - u - Updating game state type,
-- - v - Vicinity (map tile) attribute type.
--
--
-- Internally, a Game consists of:
--
--
-- 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
--
data Game t s u v
-- | 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, and
-- returns an updated Game along with a result value (a):
--
--
-- newtype IOGame t s u v a = IOG (Game t s u v -> IO (Game t s u v,a))
--
--
-- The name IOGame was chosen to remind that each action deals with a
-- Game, but an IO operation can also be performed between game actions
-- (such as the reading of a file or printing something in the prompt).
data IOGame t s u v a
createGame :: GameMap v -> [ObjectManager s] -> WindowConfig -> u -> t -> FilePictureList -> IO (Game t s u v)
runIOGame :: IOGame t s u v a -> Game t s u v -> IO (Game t s u v, a)
runIOGameM :: IOGame t s u v a -> Game t s u v -> IO ()
liftIOtoIOGame :: IO a -> IOGame t s u v a
liftIOtoIOGame' :: (a -> IO ()) -> a -> IOGame t s u v ()
getGameState :: IOGame t s u v u
setGameState :: u -> IOGame t s u v ()
getGameAttribute :: IOGame t s u v t
setGameAttribute :: t -> IOGame t s u v ()
getGameFlags :: IOGame t s u v GameFlags
setGameFlags :: GameFlags -> IOGame t s u v ()
enableGameFlags :: IOGame t s u v ()
disableGameFlags :: IOGame t s u v ()
enableMapDrawing :: IOGame t s u v ()
disableMapDrawing :: IOGame t s u v ()
enableObjectsDrawing :: IOGame t s u v ()
disableObjectsDrawing :: IOGame t s u v ()
enableObjectsMoving :: IOGame t s u v ()
disableObjectsMoving :: IOGame t s u v ()
-- | draws the background map
drawMap :: IOGame t s u v ()
-- | paint the whole screen with a specified RGB color
clearScreen :: GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
-- | returns a mapTile, given its index (x,y) in the tile map
getTileFromIndex :: (Int, Int) -> IOGame t s u v (Tile v)
-- | returns a mapTile, given its pixel position (x,y) in the screen
getTileFromWindowPosition :: (GLdouble, GLdouble) -> IOGame t s u v (Tile v)
-- | set the current map for a MultiMap
setCurrentMapIndex :: Int -> IOGame t s u v ()
getObjectManagers :: IOGame t s u v [ObjectManager s]
setObjectManagers :: [ObjectManager s] -> IOGame t s u v ()
-- | draws all visible objects
drawAllObjects :: IOGame t s u v ()
-- | draw one object
drawObject :: GameObject s -> IOGame t s u v ()
-- | changes objects position according to its speed
moveAllObjects :: IOGame t s u v ()
-- | destroys objects from the game
destroyObjects :: [GameObject s] -> IOGame t s u v ()
-- | destroys an object from the game
destroyObject :: GameObject s -> IOGame t s u v ()
-- | returns the list of all objects from the group whose name is given
getObjectsFromGroup :: String -> IOGame t s u v [GameObject s]
-- | adds an object to a previously created group
addObjectsToGroup :: [GameObject s] -> String -> IOGame t s u v ()
-- | adds an object to a new group
addObjectsToNewGroup :: [GameObject s] -> String -> IOGame t s u v ()
-- | returns an object manager of the game, given its name (internal use)
findObjectManager :: String -> IOGame t s u v (ObjectManager s)
-- | returns an object of the game, given its name and is object manager
-- name
findObject :: String -> String -> IOGame t s u v (GameObject s)
-- | there is no need to search through the managers, because the name of
-- an object is never modified so the result of this function will always
-- be safe.
getObjectName :: GameObject s -> IOGame t s u v String
-- | because an object can have its group (manager) name modified, it is
-- necessary to search through the managers to find it, otherwise this
-- functions won't be safe.
getObjectGroupName :: GameObject s -> IOGame t s u v String
-- | because an object can have its sleeping status modified, it is
-- necessary to search through the managers to find it, otherwise this
-- functions won't be safe.
getObjectAsleep :: GameObject s -> IOGame t s u v Bool
-- | because an object can have its size modified, it is necessary to
-- search through the managers to find it, otherwise this functions won't
-- be safe.
getObjectSize :: GameObject s -> IOGame t s u v (GLdouble, GLdouble)
-- | because an object can have its position modified, it is necessary to
-- search through the managers to find it, otherwise this functions won't
-- be safe.
getObjectPosition :: GameObject s -> IOGame t s u v (GLdouble, GLdouble)
-- | because an object can have its speed modified, it is necessary to
-- search through the managers to find it, otherwise this functions won't
-- be safe.
getObjectSpeed :: GameObject s -> IOGame t s u v (GLdouble, GLdouble)
-- | because an object can have its attribute modified, it is necessary to
-- search through the managers to find it, otherwise this functions won't
-- be safe.
getObjectAttribute :: GameObject s -> IOGame t s u v s
-- | changes the position of an object, given its new position
setObjectPosition :: (GLdouble, GLdouble) -> GameObject s -> IOGame t s u v ()
-- | changes the sleeping status of an object, given its new status
setObjectAsleep :: Bool -> GameObject s -> IOGame t s u v ()
-- | changes the speed of an object, given its new speed
setObjectSpeed :: (GLdouble, GLdouble) -> GameObject s -> IOGame t s u v ()
-- | changes the current picture of a multitextured object
setObjectCurrentPicture :: Int -> GameObject s -> IOGame t s u v ()
-- | changes the attribute of an object, given its new attribute
setObjectAttribute :: s -> GameObject s -> IOGame t s u v ()
-- | replaces an object by a new one, given the old object and the function
-- that must be applied to it.
replaceObject :: GameObject s -> (GameObject s -> GameObject s) -> IOGame t s u v ()
reverseXSpeed :: GameObject s -> IOGame t s u v ()
reverseYSpeed :: GameObject s -> IOGame t s u v ()
-- | checks the collision between two objects
objectsCollision :: GameObject s -> GameObject s -> IOGame t s u v Bool
-- | checks the collision between two objects in the next game cicle
objectsFutureCollision :: GameObject s -> GameObject s -> IOGame t s u v Bool
objectListObjectCollision :: [GameObject s] -> GameObject s -> IOGame t s u v Bool
objectListObjectFutureCollision :: [GameObject s] -> GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the top of the map
objectTopMapCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the bottom of the map
objectBottomMapCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the right side of the map
objectRightMapCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the left side of the map
objectLeftMapCollision :: GameObject s -> IOGame t s u v Bool
pointsObjectCollision :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> GameObject s -> IOGame t s u v Bool
pointsObjectListCollision :: GLdouble -> GLdouble -> GLdouble -> GLdouble -> [GameObject s] -> IOGame t s u v Bool
-- | checks the collision between an object and the top of the map in the
-- next game cicle
objectTopMapFutureCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the bottom of the map in
-- the next game cicle
objectBottomMapFutureCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the right side of the map
-- in the next game cicle
objectRightMapFutureCollision :: GameObject s -> IOGame t s u v Bool
-- | checks the collision between an object and the left side of the map in
-- the next game cicle
objectLeftMapFutureCollision :: GameObject s -> IOGame t s u v Bool
-- | prints a string in the prompt
printOnPrompt :: Show a => a -> IOGame t s u v ()
-- | prints a string in the current window
printOnScreen :: String -> BitmapFont -> (GLdouble, GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
-- | internal use of the engine
printText :: IOGame t s u v ()
randomFloat :: (Float, Float) -> IOGame t s u v Float
randomInt :: (Int, Int) -> IOGame t s u v Int
randomDouble :: (Double, Double) -> IOGame t s u v Double
-- | shows the frame rate (or frame per seconds)
showFPS :: BitmapFont -> (GLdouble, GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v ()
-- | delay for N seconds while continuing essential game functions
wait :: Int -> IOGame t s u v ()
-- | Given a fungen Game and IOGame step action, generate a GLUT display
-- callback that steps the game and renders its resulting state.
-- funInit runs this automatically.
display :: Game t s u v -> IOGame t s u v () -> DisplayCallback
texCoord2 :: GLdouble -> GLdouble -> IO ()
vertex3 :: GLdouble -> GLdouble -> GLdouble -> IO ()
texStuff :: [TextureObject] -> [AwbfBitmap] -> IO ()
toRad :: Float -> Float
randInt :: (Int, Int) -> IO Int
randFloat :: (Float, Float) -> IO Float
randDouble :: (Double, Double) -> IO Double
shiftLeft :: String -> Int -> String
toDecimal :: String -> GLsizei
pow2 :: GLsizei -> GLsizei
toBinary :: Int -> String
make0 :: Int -> String
dropGLsizei :: GLsizei -> [a] -> [a]
ord2 :: Char -> GLubyte
-- | to be used when no invisibility must be added when loading a file
addNoInvisibility :: [FilePath] -> [(FilePath, Maybe ColorList3)]
racMod :: GLdouble -> GLdouble -> GLdouble
matrixToList :: [[a]] -> [a]
-- | return the max indexes of a matrix (assumed that its lines have the
-- same length)
matrixSize :: [[a]] -> (Int, Int)
inv2color3 :: InvList -> Maybe ColorList3
pathAndInv2color3List :: (FilePath, InvList) -> (FilePath, Maybe ColorList3)
point2DtoVertex3 :: [Point2D] -> [Vertex3 GLdouble]
isEmpty :: [a] -> Bool
when :: Monad m => Bool -> m () -> m ()
unless :: Monad m => Bool -> m () -> m ()
bindTexture :: TextureTarget2D -> TextureObject -> IO ()
-- | trace an expression using a custom show function
tracewith :: (a -> String) -> a -> a
-- | trace a showable expression
strace :: Show a => a -> a
-- | labelled trace - like strace, with a label prepended
ltrace :: Show a => String -> a -> a
-- | monadic trace - like strace, but works as a standalone line in a monad
mtrace :: (Monad m, Show a) => a -> m a