|
| static void | setFps (int val) |
| | The setFps function allows you to limit the number of frames per second. If a frame is rendered faster than expected, the TCOD_console_flush 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. You should always limit the frame rate, except during benchmarks, else your game will use 100% of the CPU power.
|
|
static int | getFps () |
| | The value returned by this function is updated every second.
|
|
static float | getLastFrameLength () |
| | Return the duration of the last frame in seconds.
|
| static void | sleepMilli (uint32_t val) |
| | Use this function to stop the program execution for a specified number of milliseconds.
|
|
static uint32_t | getElapsedMilli () |
| | This function returns the number of milliseconds since the program has started.
|
|
static float | getElapsedSeconds () |
| | This function returns the number of seconds since the program has started.
|
| static TCODLIB_BEGIN_IGNORE_DEPRECATIONS TCOD_event_t | waitForEvent (int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush) |
| | This function waits for an event from the user.
|
| static TCOD_event_t | checkForEvent (int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse) |
| | This function checks if an event from the user is in the buffer.
|
| static TCODLIB_END_IGNORE_DEPRECATIONS void | saveScreenshot (const char *filename) |
| | 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.
|
| static bool | createDirectory (const char *path) |
| static bool | deleteDirectory (const char *path) |
| static bool | deleteFile (const char *path) |
| static bool | isDirectory (const char *path) |
| static TCOD_list_t | getDirectoryContent (const char *path, const char *pattern) |
| | To get the list of entries in a directory (including sub-directories, except .
|
| static bool | fileExists (const char *filename,...) |
| | In order to check whether a given file exists in the filesystem.
|
| static bool | readFile (const char *filename, unsigned char **buf, size_t *size) |
| | This is a portable function to read the content of a file from disk or from the application apk (android).
|
| static bool | writeFile (const char *filename, unsigned char *buf, uint32_t size) |
| | This is a portable function to write some data to a file.
|
| static void | registerSDLRenderer (ITCODSDLRenderer *renderer) |
| | To disable the custom renderer, call the same method with a NULL parameter. Note that to keep libtcod from requiring the SDL headers, the callback parameter is a void pointer. You have to include SDL headers and cast it to SDL_Surface in your code.class TCODLIB_API ITCODSDLRenderer { public : virtual void render(void *sdlSurface) = 0; }; static void TCODSystem::registerSDLRenderer(ITCODSDLRenderer *callback);typedef void (*SDL_renderer_t) (void *sdl_surface); void TCOD_sys_register_SDL_renderer(SDL_renderer_t callback)def renderer ( sdl_surface ) : ... TCOD_sys_register_SDL_renderer( callback ).
|
| static void | forceFullscreenResolution (int width, int height) |
| | libtcod is not aware of the part of the screen your SDL renderer has updated.
|
| static void | getCurrentResolution (int *width, int *height) |
| | You can get the current screen resolution with getCurrentResolution.
|
| static void | getFullscreenOffsets (int *offset_x, int *offset_y) |
| | If the fullscreen resolution does not matches the console size in pixels, black borders are added.
|
| static void | getCharSize (int *w, int *h) |
| | You can get the size of the characters in the font.
|
| static void | updateChar (int asciiCode, int font_x, int font_y, const TCODImage *img, int x, int y) |
| | You can dynamically change the bitmap of a character in the font.
|
| static void | setRenderer (TCOD_renderer_t renderer) |
| | As of 1.5.1, libtcod contains 3 different renderers : SDL : historic libtcod renderer.
|
|
static TCOD_renderer_t | getRenderer () |
| static bool | setClipboard (const char *value) |
| | 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.
|
| static char * | getClipboard () |
| | Returns the UTF-8 text currently in the system clipboard.
|
|
static int | getNumCores () |
|
static TCOD_thread_t | newThread (int(*func)(void *), void *data) |
|
static void | deleteThread (TCOD_thread_t th) |
|
static void | waitThread (TCOD_thread_t th) |
|
static TCOD_mutex_t | newMutex () |
|
static void | mutexIn (TCOD_mutex_t mut) |
|
static void | mutexOut (TCOD_mutex_t mut) |
|
static void | deleteMutex (TCOD_mutex_t mut) |
|
static TCOD_semaphore_t | newSemaphore (int initVal) |
|
static void | lockSemaphore (TCOD_semaphore_t sem) |
|
static void | unlockSemaphore (TCOD_semaphore_t sem) |
|
static void | deleteSemaphore (TCOD_semaphore_t sem) |
|
static TCOD_cond_t | newCondition () |
|
static void | signalCondition (TCOD_cond_t sem) |
|
static void | broadcastCondition (TCOD_cond_t sem) |
|
static void | waitCondition (TCOD_cond_t sem, TCOD_mutex_t mut) |
|
static void | deleteCondition (TCOD_cond_t sem) |
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.
TCOD_EVENT_KEY_PRESS=1, TCOD_EVENT_KEY_RELEASE=2, TCOD_EVENT_KEY=TCOD_EVENT_KEY_PRESS|TCOD_EVENT_KEY_RELEASE, TCOD_EVENT_MOUSE_MOVE=4, TCOD_EVENT_MOUSE_PRESS=8, TCOD_EVENT_MOUSE_RELEASE=16, TCOD_EVENT_MOUSE=TCOD_EVENT_MOUSE_MOVE|TCOD_EVENT_MOUSE_PRESS|TCOD_EVENT_MOUSE_RELEASE, TCOD_EVENT_ANY=TCOD_EVENT_KEY|TCOD_EVENT_MOUSE, } TCOD_event_t; static TCOD_event_t TCODSystem::checkForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse)
- Parameters
-
| eventMask | event types to wait for (other types are discarded) |
| key | updated in case of a key event. Can be null if eventMask contains no key event type |
| mouse | updated in case of a mouse event. Can be null if eventMask contains no mouse event type |
TCOD_key_t key; TCOD_mouse_t mouse; TCOD_event_t ev = TCODSystem::checkForEvent(TCOD_EVENT_ANY,&key,&mouse); if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }
TCOD_key_t key; TCOD_mouse_t mouse; TCOD_event_t ev = TCOD_sys_check_for_event(TCOD_EVENT_ANY,&key,&mouse); if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }
| void TCODSystem::forceFullscreenResolution |
( |
int | width, |
|
|
int | height ) |
|
static |
libtcod is not aware of the part of the screen your SDL renderer has updated.
If no change occurred in the console, it won't redraw them except if you tell him to do so with this function
- Parameters
-
| x,y,w,h | Part of the root console you want to redraw even if nothing has changed in the console back/fore/char. |
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.
- Parameters
-
| width,height | Resolution to use when switching to fullscreen. 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 |
TCODSystem::forceFullscreenResolution(800,600); // use 800x600 in fullscreen instead of 640x400 TCODConsole::initRoot(80,50,"",true); // 80x50 console with 8x8 char => 640x400 default resolution
TCOD_sys_force_fullscreen_resolution(800,600); TCOD_console_init_root(80,50,"",true);
libtcod.sys_force_fullscreen_resolution(800,600) libtcod.console_init_root(80,50,"",True)
tcod.system.forceFullscreenResolution(800,600) – use 800x600 in fullscreen instead of 640x400 tcod.console.initRoot(80,50,"",true) – 80x50 console with 8x8 char => 640x400 default resolution
| TCODLIB_BEGIN_IGNORE_DEPRECATIONS TCOD_event_t TCODSystem::waitForEvent |
( |
int | eventMask, |
|
|
TCOD_key_t * | key, |
|
|
TCOD_mouse_t * | mouse, |
|
|
bool | flush ) |
|
static |
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.
TCOD_EVENT_NONE=0, TCOD_EVENT_KEY_PRESS=1, TCOD_EVENT_KEY_RELEASE=2, TCOD_EVENT_KEY=TCOD_EVENT_KEY_PRESS|TCOD_EVENT_KEY_RELEASE, TCOD_EVENT_MOUSE_MOVE=4, TCOD_EVENT_MOUSE_PRESS=8, TCOD_EVENT_MOUSE_RELEASE=16, TCOD_EVENT_MOUSE=TCOD_EVENT_MOUSE_MOVE|TCOD_EVENT_MOUSE_PRESS|TCOD_EVENT_MOUSE_RELEASE, TCOD_EVENT_ANY=TCOD_EVENT_KEY|TCOD_EVENT_MOUSE, } TCOD_event_t; static TCOD_event_t TCODSystem::waitForEvent(int eventMask, TCOD_key_t *key, TCOD_mouse_t *mouse, bool flush)
- Parameters
-
| eventMask | event types to wait for (other types are discarded) |
| key | updated in case of a key event. Can be null if eventMask contains no key event type |
| mouse | updated in case of a mouse event. Can be null if eventMask contains no mouse event type |
| flush | if true, all pending events are flushed from the buffer. Else, return the first available event |
TCOD_key_t key; TCOD_mouse_t mouse; TCOD_event_t ev = TCODSystem::waitForEvent(TCOD_EVENT_ANY,&key,&mouse,true); if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }
TCOD_key_t key; TCOD_mouse_t mouse; TCOD_event_t ev = TCOD_sys_wait_for_event(TCOD_EVENT_ANY,&key,&mouse,true); if ( ev == TCOD_EVENT_KEY_PRESS && key.c == 'i' ) { ... open inventory ... }