MCPcopy Index your code
hub / github.com/amethyst/bracket-lib

github.com/amethyst/bracket-lib @0.8.7

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.8.7 ↗ · + Follow
2,021 symbols 4,408 edges 274 files 667 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Welcome to bracket-lib

You can read a tutorial series on writing a Roguelike with this library at: https://bfnightly.bracketproductions.com/rustbook/

Bracket-lib is the primary support library for my book, Hands-on Rust. Please consider checking out my book.

Early work has begun on writing a manual. You can find it in the manual folder, or read it online.

BREAKING CHANGE ALERT: The crossterm feature is now cross_term if you are using bracket-terminal directly. It's still crossterm for bracket-lib and rltk.

IMPORTANT: If you are running the webgpu backend, you need to add resolver = 2 to your Cargo.toml file. WGPU requires it for platform selection.

What happened to RLTK?

This is RLTK, renamed because it is increasingly finding usage outside of just Roguelikes. It's also been divided into a number of crates, to make it easy to pick-and-choose the features you need.

  • rltk crate wraps bracket-lib and re-exports in the rltk:: and rltk::prelude namespace. This preserves compatibility with all existing RLTK projects.
  • bracket-algorithm-traits exposes the traits required for the various algorithm systems in other crates.
  • bracket-color is my RGB/HSV color management system.
  • bracket-geometry exposes various geometric primitives and helpers. Supports other crates.
  • bracket-noise is a port of Auburn's FastNoise to Rust.
  • bracket-pathfinding provides a high-performance A* (A-Star) pathing system, as well as Dijkstra maps.
  • bracket-random is a dice-oriented random number generator, including parsing of RPG-style dice strings such as 3d6+12.

Using bracket-lib

In your Cargo.toml file, include:

[dependencies]
bracket-lib = "~0.8"

Feature Flags

There are a few feature flags designed to aide integration with other systems:

  • specs tells various bracket-lib sub-systems to export important primitives as having Specs' Component type applied.
  • serde tells various bracket-lib sub-systems to support using Serde for serialization/de-serialization.

Performance:

  • threaded enables multi-threading on some sub-systems.

Terminal mode:

By default, bracket-lib runs in OpenGL mode (or WebGL if it detects that you are compiling for wasm32-unknown-unknown). If you want to use other rendering back-ends, disable default features and apply one of the following feature flags:

  • webgpu to use the wgpu system as a back-end, supporting Vulkan, Metal and WebGPU.
  • crossterm to use the excellent Crossterm terminal library.
  • curses to use pancurses for ncurses or pdcurses support depending upon your platform.

Sample Projects

  • https://github.com/Micutio/innit
  • https://github.com/amethyst/shotcaller
  • https://github.com/bofh69/rouge
  • https://github.com/carsin/miners
  • https://github.com/baszalmstra/my-little-robots
  • https://github.com/Havegum/Terrain-Generator
  • https://github.com/Bobox214/rs-gliphus
  • https://github.com/Maxgy/blademaster
  • https://github.com/Maxgy/text-rts

Extension points exported contracts — how you extend this code

GameState (Interface)
Implement this trait on your state struct, so the engine knows what to call on each tick. [48 implementers]
bracket-terminal/src/gamestate.rs
Algorithm3D (Interface)
Implement these for handling conversion to/from 2D coordinates (they are separate, because you might want Dwarf Fortress [7 …
bracket-algorithm-traits/src/algorithm3d.rs
ConsoleFrontEnd (Interface)
(no doc) [3 implementers]
bracket-bevy/src/consoles/mod.rs
Console (Interface)
Trait that must be implemented by console types. [5 implementers]
bracket-terminal/src/consoles/console.rs
Algorithm2D (Interface)
Implement these for handling conversion to/from 2D coordinates (they are separate, because you might want Dwarf Fortress [21 …
bracket-algorithm-traits/src/algorithm2d.rs
SimpleConsoleBackend (Interface)
(no doc) [2 implementers]
bracket-bevy/src/consoles/simple_console/back_end/mod.rs
BaseMap (Interface)
Implement this trait to support path-finding functions. [31 implementers]
bracket-algorithm-traits/src/basemap.rs
SparseConsoleBackend (Interface)
(no doc) [2 implementers]
bracket-bevy/src/consoles/sparse_console/back_end/mod.rs

Core symbols most depended-on inside this repo

len
called by 99
bracket-terminal/src/hal/webgpu/backing/index_array_helper.rs
val_coord_3d_fast
called by 72
bracket-noise/src/fastnoise.rs
for_each
called by 63
bracket-geometry/src/rect.rs
to_cp437
called by 61
bracket-bevy/src/cp437.rs
print_color
called by 55
bracket-bevy/src/context.rs
to_cp437
called by 53
bracket-terminal/src/consoles/text/codepage437.rs
point2d_to_index
called by 52
bracket-algorithm-traits/src/algorithm2d.rs
fast_abs_f
called by 51
bracket-noise/src/fastnoise.rs

Shape

Method 1,277
Function 466
Class 216
Enum 54
Interface 8

Languages

Rust100%

Modules by API surface

bracket-noise/src/fastnoise.rs130 symbols
bracket-terminal/src/bterm.rs70 symbols
bracket-terminal/src/consoles/command_buffer.rs51 symbols
bracket-bevy/src/consoles/draw_batch.rs47 symbols
bracket-terminal/src/consoles/virtual_console.rs42 symbols
bracket-bevy/src/context.rs42 symbols
bracket-terminal/src/consoles/sprite_console.rs41 symbols
bracket-terminal/src/consoles/flexible_console.rs41 symbols
bracket-terminal/src/consoles/sparse_console.rs40 symbols
bracket-terminal/src/consoles/simple_console.rs39 symbols
bracket-bevy/src/consoles/virtual_console.rs37 symbols
bracket-bevy/src/consoles/sparse_console/front_end.rs37 symbols

For agents

$ claude mcp add bracket-lib \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact