Skip to content

The card system

Tilemap / ASCII-art map parsing for procedural world generation and room layouts.

Overview

Cards are tile-based layouts defined in ASCII art or structured data. The card system parses these maps and provides helpers for reading tile data, placing objects based on tile positions, and querying tile contents. It is most commonly used for procedural dungeon-style or room-layout generation.

A card definition assigns each character in the ASCII map to a tile type with associated spawn rules. card_get retrieves a parsed card by name; card_spawn instantiates the card's objects into the simulation.

Quick example

== setup ==
layout = card_get("station_interior")
card_spawn(layout, offset_x=1000, offset_z=2000)
from sbs_utils.cards.card import card_get, card_spawn

layout = card_get("station_interior")
card_spawn(layout, offset_x=1000, offset_z=2000)

API

Card

Bases: CardList

A card is not the space objects

Deck

Bases: CardList

draw(card)

Draws the card specified or picks one

Parameters:

Name Type Description Default
card _type_

The card to draw.

required

Returns:

Name Type Description
_type_

card drawn

Tilemap

Bases: CardList

fill(tile_string, layer=None, x_count=0, scale_tile=1, x_offset=0, z_offset=0, shift=0)

summary

Parameters:

Name Type Description Default
tile_string _type_

description

required
layer _type_

description. Defaults to None.

None
x_count int

description. Defaults to 0.

0
scale_tile int

description. Defaults to 1.

1
x_offset int

description. Defaults to 0.

0
z_offset int

description. Defaults to 0.

0
shift int

Offset every n line by 1/2 width. Helps simulate hex like grid with n=2. Default = 0

0

fill_hex_rings(tile_string, layer=None)

fill_hex_rings creates a hex map

Parameters:

Name Type Description Default
tile_string _type_

The string of contents

required
layer _type_

name of the layer

None