Module tcod::console
[−]
[src]
The console emulator handles the rendering of the game screen and the keyboard input
It provides the necessary traits and types for working with the different console types,
including the Console trait and the
Root and Offscreen console types.
It's worth mentioning that only one Root
console may exist at any given time, and it has to
be initialized at the start of the program.
Examples
Initializing the Root
console and creating an Offscreen
console:
use tcod::console::{Root, Offscreen}; let mut root = Root::initializer().init(); let (width, height) = (80, 30); let mut offscreen = Offscreen::new(width, height);
A typical tcod-rs
program's basic structure would look something like this:
use tcod::console::Root; fn main() { let mut root = Root::initializer().init(); // Replace with custom initialization code while !root.window_closed() { // Handling user input // Updating the gamestate // Rendering the results } }
For detailed examples on the user input handling and rendering see the Root struct's documentation.
Additional Information
The Root
and Console
types are also reexported in the root module (tcod
) under the names
RootConsole
and OffscreenConsole
, making the following code sample equivalent to the
previous one:
use tcod::{RootConsole, OffscreenConsole}; let mut root = RootConsole::initializer().init(); let (width, height) = (80, 30); let mut offscreen = OffscreenConsole::new(width, height);
This applies to all the examples in the rest of the modules documentation.
Structs
Offscreen |
A type representing secondary consoles |
Root | |
RootInitializer |
Helper struct for the |
Enums
BackgroundFlag |
This flag determines how a cell's existing background color will be modified by a new one |
FontLayout |
All the possible font layouts that can be used for custom bitmap fonts |
FontType | |
Renderer |
All the possible renderers used by the |
TextAlignment |
Represents the text alignment in console instances. |
Traits
AsciiLiteral | |
Console |
Defines the common functionality between |
TcodString |
Functions
blit |
Blits the contents of one console onto an other |