create-asciitorium 0.1.45 → 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.
- package/dist/templates/base/ASCIITORIUM_REFERENCE.md +187 -134
- package/dist/templates/base/public/art/README.md +23 -96
- package/dist/templates/base/public/art/font/README.md +113 -0
- package/dist/templates/base/public/art/fonts/README.md +113 -0
- package/dist/templates/base/public/art/maps/README.md +87 -190
- package/dist/templates/base/public/art/materials/README.md +81 -207
- package/dist/templates/base/public/art/sounds/README.md +9 -0
- package/dist/templates/base/public/art/sprites/README.md +136 -0
- package/dist/templates/base/src/main.tsx +4 -4
- package/dist/templates/base/src/reference-validation.tsx +1 -1
- package/package.json +1 -1
|
@@ -1,115 +1,42 @@
|
|
|
1
1
|
# Art Directory
|
|
2
2
|
|
|
3
|
-
This directory contains
|
|
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
|
-
|
|
5
|
+
## Asset Loading
|
|
56
6
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
24
|
+
### [fonts/](fonts/README.md)
|
|
94
25
|
|
|
95
|
-
|
|
26
|
+
ASCII font definitions for `Banner` component rendering. See the fonts README for file format details.
|
|
96
27
|
|
|
97
|
-
|
|
28
|
+
### [maps/](maps/README.md)
|
|
98
29
|
|
|
99
|
-
|
|
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
|
-
|
|
32
|
+
### [materials/](materials/README.md)
|
|
105
33
|
|
|
106
|
-
|
|
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
|
-
|
|
36
|
+
### [sounds/](sounds/README.md)
|
|
109
37
|
|
|
110
|
-
|
|
38
|
+
Audio files in MP3 format used throughout the application. See the sounds README for usage details.
|
|
111
39
|
|
|
112
|
-
|
|
113
|
-
- `wolf.art` - ASCII sprite for wolf creature
|
|
40
|
+
### [sprites/](sprites/README.md)
|
|
114
41
|
|
|
115
|
-
|
|
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.
|