Add Material Skill
Adds a new terrain material definition to the Asciicker material system.
Material System Overview
The material system supports 256 materials (IDs 0-255):
- •Material 0: Water (blue-gray,
,!glyphs) - •Material 1: Grass (green,
"'`glyphs) - •Materials 2-255: Available for new materials
Each material has:
- •4 elevation ramps (for height variation)
- •16 shade levels (for lighting/shadows)
- •Background color (RGB)
- •Foreground color (RGB)
- •Glyph (ASCII character)
Quick Start: Add a New Material
Example: Adding Dirt (Material 2)
- •Open asciiid.cpp
- •Find the material initialization code (around line 483)
- •Add material definition after grass
Material Definition Template
cpp
// MATERIAL X: [NAME] (explicitly defined)
uint8_t [name]_bg_base[3] = {R, G, B}; // Background base color
uint8_t [name]_fg_base[3] = {R, G, B}; // Foreground base color
uint8_t [name]_glyphs[4] = {'A', 'B', 'C', 'D'}; // Glyphs for 4 ramps
for (int r = 0; r < 4; r++) // For each elevation ramp
{
for (int s = 0; s < 16; s++) // For each shade level
{
float shade_factor = 1.0f - (s / 16.0f) * 0.6f; // Darken by up to 60%
m[X].shade[r][s].bg[0] = (uint8_t)([name]_bg_base[0] * shade_factor);
m[X].shade[r][s].bg[1] = (uint8_t)([name]_bg_base[1] * shade_factor);
m[X].shade[r][s].bg[2] = (uint8_t)([name]_bg_base[2] * shade_factor);
m[X].shade[r][s].fg[0] = (uint8_t)([name]_fg_base[0] * shade_factor);
m[X].shade[r][s].fg[1] = (uint8_t)([name]_fg_base[1] * shade_factor);
m[X].shade[r][s].fg[2] = (uint8_t)([name]_fg_base[2] * shade_factor);
m[X].shade[r][s].glyph = [name]_glyphs[r];
}
}
Common Material Types
Dirt/Soil:
- •Background: Brown RGB(139, 90, 43)
- •Foreground: Light brown RGB(205, 133, 63)
- •Glyphs:
:,;,.,,
Stone/Rock:
- •Background: Dark gray RGB(70, 70, 70)
- •Foreground: Light gray RGB(150, 150, 150)
- •Glyphs:
#,▓,▒,░
Sand:
- •Background: Sandy yellow RGB(238, 214, 175)
- •Foreground: Light yellow RGB(255, 248, 220)
- •Glyphs:
.,·,°,˙
Snow:
- •Background: White RGB(240, 248, 255)
- •Foreground: Bright white RGB(255, 255, 255)
- •Glyphs:
*,❄,·,˙
Lava:
- •Background: Dark red RGB(139, 0, 0)
- •Foreground: Orange RGB(255, 140, 0)
- •Glyphs:
~,≈,∼,~
Code Location
Material definitions are in asciiid.cpp:
- •Water (Material 0): Lines ~450-482
- •Grass (Material 1): Lines ~483-516
- •Add new materials here: After line 516
After Adding a Material
- •Rebuild the editor:
make -f makefile_asciiid_mac - •Test in editor:
- •Launch editor:
./.run/asciiid - •Set brush to new Material ID
- •Paint on terrain
- •Verify colors and glyphs appear correctly
- •Launch editor:
- •Document: Add material to MATERIAL_SYSTEM_EXPLAINED.md
Instructions
When the user asks to add a new material:
- •Ask for material details:
- •Name (dirt, stone, sand, etc.)
- •Base colors (or suggest common colors)
- •Glyphs (or suggest thematic characters)
- •Read asciiid.cpp to find material initialization section
- •Add material definition after existing materials
- •Rebuild editor
- •Provide testing instructions
Related Files
- •asciiid.cpp - Material definitions
- •MATERIAL_SYSTEM_EXPLAINED.md - Documentation
- •terrain.cpp - Terrain rendering using materials