NAME

TCOD - FFI bindings for libtcod

SYNOPSIS

use TCOD;
use File::Share 'dist_file';

use constant {
    WIDTH  => 80,
    HEIGHT => 60,
};

my $tileset = TCOD::Tileset->load_tilesheet(
    path    => dist_file( TCOD => 'fonts/dejavu10x10_gs_tc.png' ),
    columns => 32,
    rows    => 8,
    charmap => TCOD::CHARMAP_TCOD,
);

my $context = TCOD::Context->new(
    columns => WIDTH,
    rows    => HEIGHT,
    tileset => $tileset,
);

my $console = $context->new_console;

while (1) {
    $console->clear;
    $console->print( 0, 0, 'Hello World!' );
    $context->present( $console );

    my $iter = TCOD::Event::wait;
    while ( my $event = $iter->() ) {
        $context->convert_event($event);
        print $event->as_string . "\n";
        exit if $event->type eq 'QUIT';
    }
}

DESCRIPTION

TCOD offers Perl bindings to libtcod, a library for developing roguelike games.

On Stability

This distribution is currently experimental, and as such, its API might still change without warning. Any change, breaking or not, will be noted in the change log, so if you wish to use it, please pin your dependencies and make sure to check the change log before upgrading.

ENUMS

The enums listed below are available as constants like the ones defined using constant, which means the same caveats apply here.

To provide introspection into the values of the enums, they are also made available as package variables with the names of each enum. This makes it possible to get the name of a value in a given enum with code like the following:

say $TCOD::Alignment{ TCOD::LEFT }; # Prints 'LEFT'

Alignment

Renderer

BackgroundFlag

This flag is used by most functions that modify a cell background color. It defines how the console's current background color is used to modify the cell's existing background color.

See the documentation for TCOD::Color for details on how color arithmetic works when referenced below.

When equations are listed below, these are applied to each individual component in turn, with new being the component for the new color, old being the one for the current one, and white standing in for the maximum value for a color component (255).

ColorControl

Keycode

Char

FontFlag

FOV

RandomAlgo

Distribution

These values are used by TCOD::Random to generate random numbers.

NoiseType

Event

SHARE DATA

This distribution bundles some data to make development simpler.

You can make use of this data with a distribution like File::Share, like in this example:

use File::Share 'dist_file';
my $path = dist_file TCOD => 'fonts/dejavu10x10_gs_tc.png';

The fonts directory contains antialiased fonts that can be used with TCOD. The names of the font files are of the form:

<font_name><font_size>_<type>_<layout>.png

<type>   : aa 32 bits png with alpha channel
           gs 24 bits or greyscale PNG

<layout> : as standard ASCII layout
           ro standard ASCII layout in row
           tc TCOD layout

The terminal8x8 font is provided is every possible format as en example.

The structure of shared files is reproduced below.

share
└── fonts
    ├── dejavu10x10_gs_tc.png
    ├── dejavu12x12_gs_tc.png
    ├── dejavu16x16_gs_tc.png
    ├── dejavu8x8_gs_tc.png
    ├── dejavu_wide12x12_gs_tc.png
    ├── dejavu_wide16x16_gs_tc.png
    ├── terminal10x10_gs_tc.png
    ├── terminal10x16_gs_ro.png
    ├── terminal10x16_gs_tc.png
    ├── terminal10x18_gs_ro.png
    ├── terminal12x12_gs_ro.png
    ├── terminal16x16_gs_ro.png
    ├── terminal7x7_gs_tc.png
    ├── terminal8x12_gs_ro.png
    ├── terminal8x12_gs_tc.png
    ├── terminal8x14_gs_ro.png
    ├── terminal8x8_aa_ro.png
    ├── terminal8x8_aa_tc.png
    ├── terminal8x8_gs_ro.png
    ├── terminal8x8_gs_tc.png
    └── ucs-fonts
        └── 4x6.bdf

SEE ALSO

COPYRIGHT AND LICENSE

Copyright 2021 José Joaquín Atria

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.