tcod-haskell-0.1.0.0: Bindings to libtcod roguelike engine

Safe HaskellNone
LanguageHaskell2010

Game.TCOD.System

Synopsis

Documentation

systemStartup :: IO () Source #

Initialize global TCOD reference for system

systemShutdown :: IO () Source #

Deallocate global TCOD reference for system

withSystem :: IO a -> IO a Source #

Run action with wrapped TCOD system startup/shutdown. Exception safe and intented to be used in main function.

systemElapsedMilli :: IO Word Source #

Get global timer in milliseconds

This function returns the number of milliseconds since the program has started.

systemElapsedSeconds :: IO Double Source #

Get global timer in seconds

This function returns the number of seconds since the program has started.

systemSleepMilli :: Word -> IO () Source #

Pause the program

Use this function to stop the program execution for a specified number of milliseconds.

Note: all haskell threads on the same HEC will be paused too, try to use Haskell side delays instead of the function.

systemSetFps :: Int -> IO () Source #

Limit the frames per second

The setFps function allows you to limit the number of frames per second. If a frame is rendered faster than expected, the consoleFlush function will wait so that the frame rate never exceed this value. You can call this function during your game initialization. You can dynamically change the frame rate. Just call this function once again. bYou should always limit the frame rate, except during benchmarks, else your game will use 100% of the CPU power/b

systemGetFps :: IO Int Source #

Get the number of frames rendered during the last second

The value returned by this function is updated every second.

systemGetLastFrameLength :: IO Float Source #

Get the duration of the last frame

This function returns the length in seconds of the last rendered frame. You can use this value to update every time dependent object in the world.

systemSaveScreenshot Source #

Arguments

:: Maybe FilePath

Name of the file. If empty, a filename is automatically generated with the form "./screenshotNNN.png", NNN being the first free number (if a file named screenshot000.png already exist, screenshot001.png will be used, and so on...).

-> IO () 

This function allows you to save the current game screen in a png file, or possibly a bmp file if you provide a filename ending with .bmp.

systemForceFullscreenResolution Source #

Arguments

:: Int

width Resolution to use when switching to fullscreen.

-> Int

height Resolution to use when switching to fullscreen.

-> IO () 

Using a custom resolution for the fullscreen mode

This function allows you to force the use of a specific resolution in fullscreen mode. The default resolution depends on the root console size and the font character size.

Will use the smallest available resolution so that : resolution width >= width and resolution width >= root console width * font char width resolution width >= height and resolution height >= root console height * font char height

systemSetRenderer :: TCODRenderer -> IO () Source #

Dynamically change libtcod's internal renderer

As of 1.5.1, libtcod contains 3 different renderers : * SDL : historic libtcod renderer. Should work and be pretty fast everywhere * OpenGL : requires OpenGL compatible video card. Might be much faster or much slower than SDL, depending on the drivers * GLSDL : requires OpenGL 1.4 compatible video card with GL_ARB_shader_objects extension. Blazing fast if you have the proper hardware and drivers. This function switches the current renderer dynamically.

systemGetRenderer :: IO TCODRenderer Source #

Get the current internal renderer

systemGetCurrentResolution :: IO (Int, Int) Source #

Get current resolution

You can get the current screen resolution with getCurrentResolution. You can use it for example to get the desktop resolution before initializing the root console.

systemGetFullscreenOffsets :: IO (Int, Int) Source #

Get fullscreen offset

If the fullscreen resolution does not matches the console size in pixels, black borders are added. This function returns the position in pixels of the console top left corner in the screen.

systemGetCharSize :: IO (Int, Int) Source #

Get the font size

You can get the size of the characters in the font

systemUpdateChar Source #

Arguments

:: Char

ascii code corresponding to the character to update

-> Int

font x coordinate of the character in the bitmap font (in characters, not pixels)

-> Int

font y coordinate of the character in the bitmap font (in characters, not pixels)

-> TCODImage

img image containing the new character bitmap

-> Int

x position in pixels of the top-left corner of the character in the image

-> Int

y position in pixels of the top-left corner of the character in the image

-> IO () 

Dynamically updating the font bitmap

You can dynamically change the bitmap of a character in the font. All cells using this ascii code will be updated at next flush call.

systemClipboardSet :: String -> IO Bool Source #

Set current clipboard contents

Takes UTF-8 text and copies it into the system clipboard. On Linux, because an application cannot access the system clipboard unless a window is open, if no window is open the call will do nothing.

systemClipboardGet :: IO String Source #

Get current clipboard contents\

Returns the UTF-8 text currently in the system clipboard. On Linux, because an application cannot access the system clipboard unless a window is open, if no window is open an empty string will be returned.

systemGetSDLWindow :: IO Window Source #

Returm reference to SDL window

systemGetSDLRenderer :: IO Renderer Source #

Return reference to SDL renderer

data TCODEvent Source #

Flags to distinguish supported events

Instances

Enum TCODEvent Source #

Note that toEnum can only capture single event

Eq TCODEvent Source # 
Ord TCODEvent Source # 
Show TCODEvent Source # 
Generic TCODEvent Source # 

Associated Types

type Rep TCODEvent :: * -> * #

type Rep TCODEvent Source # 
type Rep TCODEvent = D1 (MetaData "TCODEvent" "Game.TCOD.System" "tcod-haskell-0.1.0.0-9JdFGODCf32GFoGmrQ4wdi" False) ((:+:) ((:+:) ((:+:) (C1 (MetaCons "EventNone" PrefixI False) U1) ((:+:) (C1 (MetaCons "EventKeyPress" PrefixI False) U1) (C1 (MetaCons "EventKeyRelease" PrefixI False) U1))) ((:+:) (C1 (MetaCons "EventKey" PrefixI False) U1) ((:+:) (C1 (MetaCons "EventMouseMove" PrefixI False) U1) (C1 (MetaCons "EventMousePress" PrefixI False) U1)))) ((:+:) ((:+:) (C1 (MetaCons "EventMouseRelease" PrefixI False) U1) ((:+:) (C1 (MetaCons "EventMouse" PrefixI False) U1) (C1 (MetaCons "EventFingerMove" PrefixI False) U1))) ((:+:) ((:+:) (C1 (MetaCons "EventFingerPress" PrefixI False) U1) (C1 (MetaCons "EventFingerRelease" PrefixI False) U1)) ((:+:) (C1 (MetaCons "EventFinger" PrefixI False) U1) (C1 (MetaCons "EventAny" PrefixI False) U1)))))

packTCODEvents :: Foldable f => f TCODEvent -> Int Source #

Packing event flags into bitfield

unpackTCODEvents :: Int -> Set TCODEvent Source #

Unpack events flags from bitfield. Note that EventKey, EventMouse and EventAny are in the set if any of dependent event is occured. EventNone is never occur in the set (empty set if no events) and EventAny is member of the set if any event occurs.

data TCODEventInfo Source #

Collected info about occured events in TCOD

Constructors

TCODEventInfo 

Fields

Instances

systemWaitForEvent Source #

Arguments

:: Foldable f 
=> f TCODEvent

event types to wait for (other types are discarded)

-> Bool

Flush if true, all pending events are flushed from the buffer. Else, return the first available event

-> IO TCODEventInfo 

Waiting for any event (mouse or keyboard)

This function waits for an event from the user. The eventMask shows what events we're waiting for. The return value indicate what event was actually triggered. Values in key and mouse structures are updated accordingly. If flush is false, the function waits only if there are no pending events, else it returns the first event in the buffer.

systemCheckForEvent Source #

Arguments

:: Foldable f 
=> f TCODEvent

event types to wait for (other types are discarded)

-> IO TCODEventInfo 

Checking for any event (mouse or keyboard)

This function checks if an event from the user is in the buffer. The eventMask shows what events we're waiting for. The return value indicate what event was actually found. Values in key and mouse structures are updated accordingly.

systemCreateDirectory Source #

Arguments

:: FilePath

Directory path. The immediate father directory (path/..) must exist and be writable.

-> IO Bool 

Create a directory

All those functions return false if an error occurred.

systemDeleteFile Source #

Arguments

:: FilePath

File path. This file must exist and be writable.

-> IO Bool 

Delete a file

All those functions return false if an error occurred.

systemDeleteDirectory Source #

Arguments

:: FilePath

Directory path. This directory must exist, be writable and empty

-> IO Bool 

Delete an empty directory

All those functions return false if an error occurred.

systemIsDirectory Source #

Arguments

:: FilePath

a path to check

-> IO Bool 

Check if a path is a directory

All those functions return false if an error occurred.

systemGetDirectoryContent Source #

Arguments

:: FilePath

a path to check

-> String

pattern. If empty, returns all directory entries. Else returns only entries matching the pattern. The pattern is NOT a regular expression. It can only handle one * wildcard. Examples : *.png, saveGame*, font*.png

-> IO (TCODList FilePath) 

List files in a directory

To get the list of entries in a directory (including sub-directories, except . and ..). The returned list is allocated by the function and must be deleted by you. All the const char * inside must be also freed with listClearAndDelete.

systemFileExists Source #

Arguments

:: PrintfArg r 
=> FilePath

filename the file name, using printf-like formatting

-> r

optional arguments for filename formatting

-> IO Bool 

Check if a given file exists

In order to check whether a given file exists in the filesystem. Useful for detecting errors caused by missing files.

systemReadFile :: FilePath -> IO (Maybe ByteString) Source #

Read the content of a file into memory

This is a portable function to read the content of a file from disk or from the application apk (android).

systemWriteFile :: FilePath -> ByteString -> IO Bool Source #

Write the content of a memory buffer to a file

This is a portable function to write some data to a file.

newtype TCODLibrary Source #

TCOD dynamic library reference

Constructors

TCODLibrary 

Fields

loadLibrary :: FilePath -> IO (Maybe TCODLibrary) Source #

Dynamic load of .so or .dll library.

getFunctionAddress Source #

Arguments

:: TCODLibrary

Dynamic library reference

-> String

Name of function to load

-> IO (Maybe (FunPtr a))

If succeded, then return pointer to function

Dynamic load of function from library. Not safe as type of function is not checked.

closeLibrary :: TCODLibrary -> IO () Source #

Unload dynamic library from memory