-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | FUNctional Game ENgine -- -- Multi-platform 2D game engine built on top of OpenGL & GLUT @package FunGEn @version 0.4 -- | 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. initGLUTInput :: IO (KeyBinder, StillDownHandler) instance Eq KeyEvent -- | This FunGEn module contains some functions to print text on the -- screen. Fonts supported: Bitmap9By15, Bitmap8By13, BitmapTimesRoman10, -- BitmapTimesRoman24 BitmapHelvetica10, BitmapHelvetica12, -- BitmapHelvetica18 module Graphics.UI.Fungen.Text type Text = (String, BitmapFont, (GLdouble, GLdouble), GLclampf, GLclampf, GLclampf) -- | 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 putGameText :: [Text] -> IO () -- | This FunGEn module controls timing (how time-based functions will -- behave). module Graphics.UI.Fungen.Timer data RefreshType Idle :: RefreshType Timer :: Int -> RefreshType setRefresh :: RefreshType -> StillDownHandler -> IO () -- | This FunGEn module contains the FunGEN basic types. module Graphics.UI.Fungen.Types -- | 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)] -- | This FunGEn module contains some auxiliary functions. module Graphics.UI.Fungen.Util 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 addNoInvisibility :: [FilePath] -> [(FilePath, Maybe ColorList3)] racMod :: GLdouble -> GLdouble -> GLdouble matrixToList :: [[a]] -> [a] 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 :: TextureTarget -> TextureObject -> IO () -- | This FunGEn module loads [bmp] files. module Graphics.UI.Fungen.Loader loadBitmap :: FilePath -> Maybe ColorList3 -> IO AwbfBitmap loadBitmapList :: [(FilePath, Maybe ColorList3)] -> IO [AwbfBitmap] type FilePictureList = [(FilePath, InvList)] -- | This module contains the FunGEn objects procedures module Graphics.UI.Fungen.Objects data 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 getObjectManagerName :: ObjectManager t -> String getObjectManagerCounter :: ObjectManager t -> Integer getObjectManagerObjects :: ObjectManager t -> [(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 drawGameObjects :: [(ObjectManager t)] -> QuadricPrimitive -> [TextureObject] -> IO () drawGameObject :: GameObject t -> QuadricPrimitive -> [TextureObject] -> IO () objectGroup :: String -> [(GameObject t)] -> (ObjectManager t) data ObjectManager t findObjectFromId :: GameObject t -> [(ObjectManager t)] -> GameObject t searchObjectManager :: String -> [(ObjectManager t)] -> ObjectManager t searchGameObject :: String -> ObjectManager t -> GameObject 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 addObjectsToManager :: [(GameObject t)] -> String -> [(ObjectManager t)] -> [(ObjectManager t)] moveGameObjects :: [(ObjectManager t)] -> [(ObjectManager t)] destroyGameObject :: String -> String -> [(ObjectManager t)] -> [(ObjectManager t)] instance Eq FillMode -- | This FunGEn module contains the map (game background) routines. module Graphics.UI.Fungen.Map data GameMap t type Tile t = (Int, Bool, Float, t) type TileMatrix t = [[(Tile t)]] getTilePictureIndex :: Tile t -> Int getTileBlocked :: Tile t -> Bool getTileMoveCost :: Tile t -> Float getTileSpecialAttribute :: Tile t -> t colorMap :: GLclampf -> GLclampf -> GLclampf -> GLdouble -> GLdouble -> GameMap t textureMap :: Int -> GLdouble -> GLdouble -> GLdouble -> GLdouble -> GameMap t tileMap :: TileMatrix t -> GLdouble -> GLdouble -> GameMap t multiMap :: [(GameMap t)] -> Int -> GameMap t getMapSize :: GameMap t -> Point2D isTileMap :: GameMap t -> Bool getTileMapTileMatrix :: GameMap t -> TileMatrix t getTileMapScroll :: GameMap t -> Point2D getTileMapSize :: GameMap t -> Point2D getTileMapTileSize :: GameMap t -> Point2D getCurrentMap :: GameMap t -> GameMap t updateCurrentMap :: GameMap t -> GameMap t -> GameMap t updateCurrentIndex :: GameMap t -> Int -> GameMap t isMultiMap :: GameMap t -> Bool drawGameMap :: GameMap t -> Point2D -> [TextureObject] -> IO () clearGameScreen :: GLclampf -> GLclampf -> GLclampf -> IO () -- | This FunGEn module contains some important game routines. module Graphics.UI.Fungen.Game -- | A game has the type Game t s u v, where -- -- -- -- For a mnemonic, uh... -- -- -- -- A Game consists of the following attributes, accessible via the -- accessor functions below: -- -- data Game t s u v -- | A game action (IOGame) has the type IOGame t s u v a, where -- t, s, u and v are as for Game and a is the type returned by each -- action of the game (such as the Int for IO Int). 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 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 () 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 () getObjectManagers :: IOGame t s u v [(ObjectManager s)] setObjectManagers :: [(ObjectManager s)] -> IOGame t s u v () getGameAttribute :: IOGame t s u v t setGameAttribute :: t -> IOGame t s u v () createGame :: GameMap v -> [(ObjectManager s)] -> WindowConfig -> u -> t -> FilePictureList -> IO (Game t s u v) funExit :: IOGame t s u v () drawMap :: IOGame t s u v () clearScreen :: GLclampf -> GLclampf -> GLclampf -> IOGame t s u v () getTileFromIndex :: (Int, Int) -> IOGame t s u v (Tile v) getTileFromWindowPosition :: (GLdouble, GLdouble) -> IOGame t s u v (Tile v) setCurrentMapIndex :: Int -> IOGame t s u v () drawAllObjects :: IOGame t s u v () drawObject :: GameObject s -> IOGame t s u v () moveAllObjects :: IOGame t s u v () destroyObjects :: [(GameObject s)] -> IOGame t s u v () destroyObject :: GameObject s -> IOGame t s u v () getObjectsFromGroup :: String -> IOGame t s u v [(GameObject s)] addObjectsToGroup :: [(GameObject s)] -> String -> IOGame t s u v () addObjectsToNewGroup :: [(GameObject s)] -> String -> IOGame t s u v () findObjectManager :: String -> IOGame t s u v (ObjectManager s) findObject :: String -> String -> IOGame t s u v (GameObject s) getObjectName :: GameObject s -> IOGame t s u v String getObjectGroupName :: GameObject s -> IOGame t s u v String getObjectAsleep :: GameObject s -> IOGame t s u v Bool getObjectSize :: GameObject s -> IOGame t s u v (GLdouble, GLdouble) getObjectPosition :: GameObject s -> IOGame t s u v (GLdouble, GLdouble) getObjectSpeed :: GameObject s -> IOGame t s u v (GLdouble, GLdouble) getObjectAttribute :: GameObject s -> IOGame t s u v s setObjectPosition :: (GLdouble, GLdouble) -> GameObject s -> IOGame t s u v () setObjectAsleep :: Bool -> GameObject s -> IOGame t s u v () setObjectSpeed :: (GLdouble, GLdouble) -> GameObject s -> IOGame t s u v () setObjectCurrentPicture :: Int -> GameObject s -> IOGame t s u v () setObjectAttribute :: s -> GameObject s -> IOGame t s u v () 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 () objectsCollision :: GameObject s -> GameObject s -> IOGame t s u v Bool 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 objectTopMapCollision :: GameObject s -> IOGame t s u v Bool objectBottomMapCollision :: GameObject s -> IOGame t s u v Bool objectRightMapCollision :: GameObject s -> IOGame t s u v Bool 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 objectTopMapFutureCollision :: GameObject s -> IOGame t s u v Bool objectBottomMapFutureCollision :: GameObject s -> IOGame t s u v Bool objectRightMapFutureCollision :: GameObject s -> IOGame t s u v Bool objectLeftMapFutureCollision :: GameObject s -> IOGame t s u v Bool printOnPrompt :: Show a => a -> IOGame t s u v () printOnScreen :: String -> BitmapFont -> (GLdouble, GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v () 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 showFPS :: BitmapFont -> (GLdouble, GLdouble) -> GLclampf -> GLclampf -> GLclampf -> IOGame t s u v () wait :: Int -> IOGame t s u v () instance Monad (IOGame t s u v) -- | This FunGEn module renders the game window. module Graphics.UI.Fungen.Display -- | Given a fungen Game and IOGame, generate an opengl display handler. display :: Game t s u v -> IOGame t s u v () -> DisplayCallback -- | This FunGEn module controls the user input (mouse, keyboard, -- joystick...) module Graphics.UI.Fungen.Input -- | 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 (which we use instead of GLUTInput's) is 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 () -- | A generalized view of keys data Key :: * Char :: Char -> Key SpecialKey :: SpecialKey -> Key MouseButton :: MouseButton -> Key data KeyEvent Press :: KeyEvent StillDown :: KeyEvent Release :: KeyEvent -- | 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 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 funBinding :: [InputBinding t s u v] -> Game t s u v -> IO (KeyBinder, StillDownHandler) -- | This FunGEn module contains the initialization procedures. module Graphics.UI.Fungen.Init funInit :: WindowConfig -> GameMap v -> [(ObjectManager s)] -> u -> t -> [InputBinding t s u v] -> IOGame t s u v () -> RefreshType -> FilePictureList -> IO () -- | This is the main module of FunGEN - Functional Game Engine. module Graphics.UI.Fungen