create-asciitorium 0.1.46 → 0.1.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -246,7 +246,7 @@ align="center" // Alignment (layout-specific)
246
246
 
247
247
  ```tsx
248
248
  <Column align="center" width="100%" gap={2}>
249
- <Art src="logo" />
249
+ <Art sprite="logo" />
250
250
  <Text>Welcome</Text>
251
251
  <Button>Start</Button>
252
252
  </Column>
@@ -808,63 +808,78 @@ const text = new State('initial');
808
808
  ### Basic Usage
809
809
 
810
810
  ```tsx
811
- // Load from file
812
- <Art src="logo" />
813
-
814
- // ASCII art from figlet font
815
- <Art font="standard" text="Hello" />
811
+ // Load sprite from file
812
+ <Art sprite="logo" />
816
813
 
817
814
  // Align center
818
- <Art src="banner" align="center" />
815
+ <Art sprite="banner" align="center" />
819
816
  ```
820
817
 
821
818
  ### Props
822
819
 
823
- | Prop | Type | Default | Description |
824
- | -------- | ------------------------------- | -------- | -------------------------------- |
825
- | `src` | `string` | - | Art file name (from art/ folder) |
826
- | `font` | `string` | - | Figlet font name |
827
- | `text` | `string` | - | Text to render with font |
828
- | `width` | `number \| 'auto'` | `'auto'` | Component width |
829
- | `height` | `number \| 'auto'` | `'auto'` | Component height |
830
- | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
831
- | `border` | `boolean` | `false` | Show border |
820
+ | Prop | Type | Default | Description |
821
+ | -------- | ------------------------------- | -------- | ------------------------------------ |
822
+ | `sprite` | `string` | - | Sprite file name (from art/sprites/) |
823
+ | `width` | `number \| 'auto'` | `'auto'` | Component width |
824
+ | `height` | `number \| 'auto'` | `'auto'` | Component height |
825
+ | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
826
+ | `border` | `boolean` | `false` | Show border |
832
827
 
833
828
  ### Common Patterns
834
829
 
835
- **Pattern 1: Logo from File**
830
+ **Pattern 1: Static Sprite**
836
831
 
837
832
  ```tsx
838
- // Loads from art/logo.art
839
- <Art src="logo" align="center" />
833
+ // Loads from art/sprites/logo.art
834
+ <Art sprite="logo" align="center" />
840
835
  ```
841
836
 
842
- **Pattern 2: Generated ASCII Text**
837
+ **Pattern 2: Animated Sprite**
843
838
 
844
839
  ```tsx
845
- <Art font="standard" text="Game Over" align="center" />
840
+ // Loads animated art (auto-plays)
841
+ <Art sprite="beating-heart" width={20} />
846
842
  ```
847
843
 
848
- **Pattern 3: Animated Sprite**
844
+
845
+
846
+ ## Banner
847
+
848
+ ### Basic Usage
849
849
 
850
850
  ```tsx
851
- // Loads animated art (auto-plays)
852
- <Art src="beating-heart" width={20} />
851
+ // Render text with font
852
+ <Banner font="standard" text="Hello" />
853
+
854
+ // Align center
855
+ <Banner font="shadows" text="Game Over" align="center" />
853
856
  ```
854
857
 
855
- ### Common Mistakes
858
+ ### Props
856
859
 
857
- **WRONG** - Using both src and font
860
+ | Prop | Type | Default | Description |
861
+ | --------------- | ------------------------------- | -------- | --------------------------------- |
862
+ | `font` | `string` | - | Font name (from art/fonts/) |
863
+ | `text` | `string \| State<string>` | - | Text to render with font |
864
+ | `letterSpacing` | `number` | `0` | Additional spacing between chars |
865
+ | `width` | `number \| 'auto'` | `'auto'` | Component width |
866
+ | `height` | `number \| 'auto'` | `'auto'` | Component height |
867
+ | `align` | `'left' \| 'center' \| 'right'` | `'left'` | Horizontal alignment |
868
+ | `border` | `boolean` | `false` | Show border |
869
+
870
+ ### Common Patterns
871
+
872
+ **Pattern 1: Title Screen**
858
873
 
859
874
  ```tsx
860
- <Art src="logo" font="standard" /> // Conflicting props
875
+ <Banner font="shadows" text="asciitorium" align="center" />
861
876
  ```
862
877
 
863
- **CORRECT** - Use one or the other
878
+ **Pattern 2: Reactive Text**
864
879
 
865
880
  ```tsx
866
- <Art src="logo" /> // From file
867
- <Art font="standard" text="Title" /> // Generated
881
+ const score = new State(0);
882
+ <Banner font="pixel" text={score} letterSpacing={1} />
868
883
  ```
869
884
 
870
885
 
@@ -1,115 +1,42 @@
1
1
  # Art Directory
2
2
 
3
- This directory contains ASCII art assets for a project. It is organized into subfolders for maps, materials, and sprites. Each file uses plain text or JSON for easy editing and integration.
4
-
5
- ## Asset Loading and Caching
6
-
7
- **IMPORTANT:** All assets are automatically loaded and cached by `AssetManager` using reactive `State` objects. When developing components that use assets:
8
-
9
- ### For Component Developers
10
-
11
- **✅ DO:**
12
- - Use `AssetManager.getMapState(name)` to get a reactive State for maps
13
- - Use `AssetManager.getMaterialState(name)` to get a reactive State for materials
14
- - Subscribe to the returned State to react to loading completion or changes
15
- - Use `GameWorld.getMapState()` when working with GameWorld instances
16
- - Share State references across components - the cache handles deduplication
17
-
18
- **❌ DON'T:**
19
- - Create local caches in components (Map, Set, plain objects)
20
- - Use the legacy non-reactive methods (`getMap()`, `getMaterial()`) for new code
21
- - Load the same asset multiple times - AssetManager caches automatically
22
- - Store asset data in component properties - subscribe to State instead
23
-
24
- ### Example Usage
25
-
26
- ```typescript
27
- // ✅ Correct: Use reactive State from AssetManager
28
- const materialState = AssetManager.getMaterialState('brick-wall');
29
-
30
- // Subscribe to get the value when loaded
31
- materialState.subscribe((material) => {
32
- if (material) {
33
- // Material is loaded, use it
34
- console.log('Material loaded:', material);
35
- }
36
- });
37
-
38
- // Check current value (may be null if still loading)
39
- if (materialState.value) {
40
- // Material already loaded from cache
41
- }
42
-
43
- // ✅ Correct: GameWorld automatically uses AssetManager's State cache
44
- const gameWorld = new GameWorld({ mapName: 'dungeon' });
45
- gameWorld.getMapState().subscribe((mapAsset) => {
46
- // Automatically updates when map loads
47
- });
48
-
49
- // ❌ Wrong: Don't create your own cache
50
- class MyComponent {
51
- private myCache: Map<string, Material> = new Map(); // DON'T DO THIS!
52
- }
53
- ```
3
+ This directory contains asciitorium art assets for the asciitorium framework. They are organized into categories: fonts, maps, materials, sounds, and sprites.
54
4
 
55
- ### Architecture Benefits
5
+ ## Asset Loading
56
6
 
57
- - **Single source of truth**: AssetManager is the only cache
58
- - **Automatic updates**: Components react when assets load or change
59
- - **Memory efficient**: One copy of each asset shared across all components
60
- - **Hot-reload ready**: Asset changes propagate automatically to all subscribers
61
- - **No manual cache management**: State handles all invalidation and updates
7
+ Assets are automatically loaded and cached by `AssetManager` using reactive
8
+ `State` objects. The AssetManager provides a single source of truth with
9
+ automatic caching and updates.
62
10
 
63
11
  ## Directory Structure
64
12
 
65
- ```bash
66
- public/art/
67
- ├─ maps/
68
- └─ example/
69
- ├─ map.art
70
- └─ legend.json
71
-
72
- ├─ materials/
73
- │ ├─ brick-wall.art
74
- │ └─ wooden-door.art
75
-
76
- ├─ sprites/
77
- ├─ giant-rat.art
78
- └─ wolf.art
13
+ ``` bash
14
+ art/
15
+ ├── fonts/ # ASCII font definitions
16
+ ├── maps/ # Game map layouts with legends
17
+ ├── materials/ # Wall textures and environmental materials
18
+ ├── sounds/ # Audio files (MP3)
19
+ └── sprites/ # Animated character and object sprites
79
20
  ```
80
21
 
81
- ## maps/
82
-
83
- Contains map layouts and legends for game environments. Maps are typically stored as text files with ASCII characters representing different terrain types, while legend files (JSON format) define what each character represents, including visual assets, collision properties, and gameplay entity types.
84
-
85
- **Contents:**
86
-
87
- - `example/` - Sample map directory containing:
88
- - `map.art` - ASCII representation of the map layout
89
- - `legend.json` - Character-to-entity mapping with visual assets, collision, and behavior definitions
90
-
91
- See [maps/README.md](maps/README.md) for detailed information on map file format, legend properties, and the entity/variant system.
22
+ ## Subdirectories
92
23
 
93
- ## materials/
24
+ ### [fonts/](fonts/README.md)
94
25
 
95
- Includes ASCII representations of various materials and textures that can be used in game environments. Materials define layered visual representations at different distances (here, near, middle, far) and can include proximity-based sound effects and ambient events.
26
+ ASCII font definitions for `Banner` component rendering. See the fonts README for file format details.
96
27
 
97
- **Contents:**
28
+ ### [maps/](maps/README.md)
98
29
 
99
- - `brick-wall.art` - ASCII pattern for brick wall textures
100
- - `bone.art` - Ground-placed bone material with placement metadata
101
- - `door-on-brick.art` - Door material overlaid on brick wall background
102
- - `wireframe-wall.art` - Complex wireframe demonstrating layered perspective rendering
30
+ Map layouts paired with legend metadata define the position of terrain and entities. See the maps README for format specifications and the entity system.
103
31
 
104
- See [materials/README.md](materials/README.md) for detailed information on material file format, layer system, placement properties, and the relationship between materials and legend entities.
32
+ ### [materials/](materials/README.md)
105
33
 
106
- ## sprites/
34
+ Materials are used for `FirstPersonView` textures with layered depth rendering (here, near, middle, far). Materials can include placement metadata and sound effects. See the materials README for layer syntax and properties.
107
35
 
108
- Stores animated sprite files for characters, creatures, and other game entities. Sprites support multiple frames with configurable timing and can be referenced by legend entities for dynamic visual representation.
36
+ ### [sounds/](sounds/README.md)
109
37
 
110
- **Contents:**
38
+ Audio files in MP3 format used throughout the application. See the sounds README for usage details.
111
39
 
112
- - `giant-rat.art` - ASCII sprite for giant rat creature
113
- - `wolf.art` - ASCII sprite for wolf creature
40
+ ### [sprites/](sprites/README.md)
114
41
 
115
- Sprites are referenced in map legends via the `asset` property and can be combined with entity types to define interactive game objects.
42
+ Static or animated ASCII art with frame timing are in the sprites directory. They can be added using the `Art` component. See the sprites README for animation format details.
@@ -0,0 +1,113 @@
1
+ # Asciitorium Fonts
2
+
3
+ This directory contains ASCII font files for the **Banner** component. Fonts
4
+ allow you to display large, stylized text using ASCII art characters.
5
+
6
+ ## Font File Format
7
+
8
+ Font files use the `.art` extension and follow a structured format with metadata
9
+ separators:
10
+
11
+ ### File Structure
12
+
13
+ ``` txt
14
+ § {"kind":"font"}
15
+ ¶ {"character":"A"}
16
+ ╭─╮
17
+ │ │
18
+ ├─┤
19
+ ╵ ╵
20
+
21
+ ¶ {"character":"a"}
22
+
23
+ ╭─╮
24
+ ╭─┤
25
+ ╰─╰
26
+
27
+ ¶ {"character":["b", "B"]}
28
+
29
+ ├─╮
30
+ │ │
31
+ ╯─╯
32
+ ```
33
+
34
+ ### Key Components
35
+
36
+ 1. **File Header** (`§` separator)
37
+ - Must start with `§ {"kind":"font"}`
38
+ - Indicates this is a font asset
39
+
40
+ 2. **Glyph Sections** (`¶` separator)
41
+ - Each glyph begins with `¶ {"character":"x"}` where `x` is the character
42
+ - Character can be a single string: `"a"`
43
+ - Or an array for multiple mappings: `["b", "B"]` (both lowercase and
44
+ uppercase)
45
+ - Glyph content follows immediately after the metadata line
46
+
47
+ 3. **Glyph Content**
48
+ - ASCII art representation of the character
49
+ - Each glyph can be any width/height
50
+ - Vertical positioning is preserved (blank lines matter!)
51
+ - Maximum font height is determined by the tallest glyph
52
+
53
+ **Tips:**
54
+
55
+ - Empty lines within glyphs are preserved to maintain vertical alignment
56
+ - The first line after the glyph metadata is part of the character (no automatic
57
+ trimming)
58
+ - Map multiple characters to the same glyph using arrays:
59
+ `{"character":["a","A"]}`
60
+ - All glyphs should have consistent height for best results (pad with empty
61
+ lines if needed)
62
+
63
+ ## Using Fonts in Your App
64
+
65
+ ### Basic Usage
66
+
67
+ ```tsx
68
+ <Banner font="pencil" text="asciitorium" />
69
+ ```
70
+
71
+ ### With Letter Spacing
72
+
73
+ ```tsx
74
+ <Banner font="marker" text="HELLO" letterSpacing={1} />
75
+ ```
76
+
77
+ ### With Reactive State
78
+
79
+ ```tsx
80
+ import { State } from 'asciitorium';
81
+
82
+ const titleText = new State<string>("Welcome");
83
+
84
+ <Banner font="shadows" text={titleText} align="center" />
85
+ ```
86
+
87
+ ### Available Props
88
+
89
+ - `font` (required): Name of the font file (without `.art` extension)
90
+ - `text`: String or `State<string>` to render
91
+ - `letterSpacing`: Additional spacing between characters (default: 0)
92
+ - Plus all standard component props: `position`, `border`, `align`, `style`,
93
+ etc.
94
+
95
+ ## Technical Details
96
+
97
+ ### Loading
98
+
99
+ Fonts are loaded asynchronously via the `AssetManager`:
100
+
101
+ ```typescript
102
+ const fontAsset = await AssetManager.getFont('myfont');
103
+ ```
104
+
105
+ ### Caching
106
+
107
+ Font assets are cached on first load - subsequent uses of the same font reuse
108
+ the cached data.
109
+
110
+ ### Fallback Rendering
111
+
112
+ If a character is not found in the font, the Banner component renders the
113
+ character itself as a single-width glyph on the top line.
@@ -0,0 +1,113 @@
1
+ # Asciitorium Fonts
2
+
3
+ This directory contains ASCII font files for the **Banner** component. Fonts
4
+ allow you to display large, stylized text using ASCII art characters.
5
+
6
+ ## Font File Format
7
+
8
+ Font files use the `.art` extension and follow a structured format with metadata
9
+ separators:
10
+
11
+ ### File Structure
12
+
13
+ ``` txt
14
+ § {"kind":"font"}
15
+ ¶ {"character":"A"}
16
+ ╭─╮
17
+ │ │
18
+ ├─┤
19
+ ╵ ╵
20
+
21
+ ¶ {"character":"a"}
22
+
23
+ ╭─╮
24
+ ╭─┤
25
+ ╰─╰
26
+
27
+ ¶ {"character":["b", "B"]}
28
+
29
+ ├─╮
30
+ │ │
31
+ ╯─╯
32
+ ```
33
+
34
+ ### Key Components
35
+
36
+ 1. **File Header** (`§` separator)
37
+ - Must start with `§ {"kind":"font"}`
38
+ - Indicates this is a font asset
39
+
40
+ 2. **Glyph Sections** (`¶` separator)
41
+ - Each glyph begins with `¶ {"character":"x"}` where `x` is the character
42
+ - Character can be a single string: `"a"`
43
+ - Or an array for multiple mappings: `["b", "B"]` (both lowercase and
44
+ uppercase)
45
+ - Glyph content follows immediately after the metadata line
46
+
47
+ 3. **Glyph Content**
48
+ - ASCII art representation of the character
49
+ - Each glyph can be any width/height
50
+ - Vertical positioning is preserved (blank lines matter!)
51
+ - Maximum font height is determined by the tallest glyph
52
+
53
+ **Tips:**
54
+
55
+ - Empty lines within glyphs are preserved to maintain vertical alignment
56
+ - The first line after the glyph metadata is part of the character (no automatic
57
+ trimming)
58
+ - Map multiple characters to the same glyph using arrays:
59
+ `{"character":["a","A"]}`
60
+ - All glyphs should have consistent height for best results (pad with empty
61
+ lines if needed)
62
+
63
+ ## Using Fonts in Your App
64
+
65
+ ### Basic Usage
66
+
67
+ ```tsx
68
+ <Banner font="pencil" text="asciitorium" />
69
+ ```
70
+
71
+ ### With Letter Spacing
72
+
73
+ ```tsx
74
+ <Banner font="marker" text="HELLO" letterSpacing={1} />
75
+ ```
76
+
77
+ ### With Reactive State
78
+
79
+ ```tsx
80
+ import { State } from 'asciitorium';
81
+
82
+ const titleText = new State<string>("Welcome");
83
+
84
+ <Banner font="shadows" text={titleText} align="center" />
85
+ ```
86
+
87
+ ### Available Props
88
+
89
+ - `font` (required): Name of the font file (without `.art` extension)
90
+ - `text`: String or `State<string>` to render
91
+ - `letterSpacing`: Additional spacing between characters (default: 0)
92
+ - Plus all standard component props: `position`, `border`, `align`, `style`,
93
+ etc.
94
+
95
+ ## Technical Details
96
+
97
+ ### Loading
98
+
99
+ Fonts are loaded asynchronously via the `AssetManager`:
100
+
101
+ ```typescript
102
+ const fontAsset = await AssetManager.getFont('myfont');
103
+ ```
104
+
105
+ ### Caching
106
+
107
+ Font assets are cached on first load - subsequent uses of the same font reuse
108
+ the cached data.
109
+
110
+ ### Fallback Rendering
111
+
112
+ If a character is not found in the font, the Banner component renders the
113
+ character itself as a single-width glyph on the top line.