hascii 0.1.0 → 0.1.1

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/Makefile CHANGED
@@ -1,19 +1,8 @@
1
- .PHONY: build check test pack publish publish-dry
1
+ .PHONY: deploy
2
2
 
3
- build:
4
- bun run build
5
-
6
- check:
3
+ deploy:
7
4
  bun run check
8
-
9
- test:
10
5
  bun test
11
-
12
- pack:
13
- npm pack --dry-run
14
-
15
- publish-dry:
16
- npm publish --dry-run
17
-
18
- publish:
6
+ bun run format
7
+ bun run build
19
8
  npm publish
package/README.md CHANGED
@@ -1,23 +1,21 @@
1
- # Hascii
2
-
3
- YAML-based fantasy console for the terminal.
1
+ YAML ベースのファンタジーコンソール。ターミナルで動作する。
4
2
 
5
3
  ## Install
6
4
 
7
5
  ```bash
8
- npm install -g hascii
6
+ bun add -g hascii
9
7
  ```
10
8
 
11
9
  ## Usage
12
10
 
13
11
  ```bash
14
- # Start TUI console
12
+ # TUI コンソールを起動
15
13
  hascii
16
14
 
17
- # Run a cartridge file
15
+ # カートリッジファイルを実行
18
16
  hascii game.yaml
19
17
 
20
- # Open in editor
18
+ # エディタで開く
21
19
  hascii -e game.yaml
22
20
  ```
23
21
 
@@ -30,7 +28,22 @@ hascii -e game.yaml
30
28
  | X / K | Action B (cancel) |
31
29
  | ESC | Exit / Back |
32
30
 
33
- ## YAML Format
31
+ ## Specs
32
+
33
+ | Item | Value |
34
+ |------|-------|
35
+ | Screen | 80x22 |
36
+ | Colors | 16 (0-15) |
37
+ | SFX | 16 slots |
38
+ | Patterns | 8 slots |
39
+ | Channels | 4ch |
40
+ | Waveforms | TRI, SAW, SQR, PLS, ORG, NOI, PHA, SIN |
41
+ | Octave | 2-5 |
42
+ | Volume | 0-7 |
43
+
44
+ ## Language
45
+
46
+ Hascii は YAML で記述する宣言的なゲーム言語。Elm アーキテクチャ (init/update/draw) に基づいている。
34
47
 
35
48
  ```yaml
36
49
  # yaml-language-server: $schema=hascii/hascii.schema.json
@@ -59,126 +72,137 @@ draw:
59
72
  - print: [score, 0, 0]
60
73
  ```
61
74
 
62
- ### Expressions
75
+ ### meta
63
76
 
64
- | Expression | Description |
65
- |------------|-------------|
66
- | `{ add: [a, b] }` | Addition |
67
- | `{ sub: [a, b] }` | Subtraction |
68
- | `{ mul: [a, b] }` | Multiplication |
69
- | `{ div: [a, b] }` | Division |
70
- | `{ mod: [a, b] }` | Modulo |
71
- | `{ min: [a, b] }` | Minimum |
72
- | `{ max: [a, b] }` | Maximum |
73
- | `{ rnd: [min, max] }` | Random integer |
74
- | `{ abs: n }` | Absolute value |
75
- | `{ floor: n }` | Floor |
76
- | `{ eq: [a, b] }` | Equal (returns 0 or 1) |
77
- | `{ lt: [a, b] }` | Less than |
78
- | `{ gt: [a, b] }` | Greater than |
79
- | `{ and: [a, b, ...] }` | Logical AND (variadic) |
80
- | `{ or: [a, b, ...] }` | Logical OR (variadic) |
81
- | `{ not: a }` | Logical NOT |
82
- | `{ at: [arr, i] }` | Array access |
83
- | `{ len: arr }` | Array length |
84
-
85
- ### Statements
77
+ ゲームのメタデータを定義する。
78
+
79
+ | Key | Description |
80
+ |-----|-------------|
81
+ | `title` | ゲームタイトル |
82
+ | `frame` | フレームレート (1-60) |
83
+ | `bg` | 背景色 (0-15) |
84
+
85
+ ### init
86
+
87
+ ゲーム開始時の初期状態を定義する。ここで定義した変数は update draw から参照できる。
86
88
 
87
89
  ```yaml
88
- # Set variables
89
- - set: { x: 10, y: 20 }
90
-
91
- # Conditional (short form)
92
- - if: condition
93
- set: { x: 0 }
94
-
95
- # Conditional (with then/else)
96
- - if: condition
97
- then:
98
- - set: { x: 1 }
99
- else:
100
- - set: { x: 0 }
101
-
102
- # Loop with index
103
- - each: items
104
- as: item
105
- index: i
106
- do:
107
- - print: [item, 0, i]
108
-
109
- # Array operations
110
- - push: { to: arr, item: value }
111
- - filter:
112
- list: arr
90
+ init:
91
+ x: 40
92
+ y: 10
93
+ items: [1, 2, 3]
94
+ player: { hp: 100, mp: 50 }
95
+ ```
96
+
97
+ ### update
98
+
99
+ 毎フレーム実行されるロジックを定義する。状態を変更するには `set` を使う。
100
+
101
+ ```yaml
102
+ update:
103
+ # 変数を設定
104
+ - set: { x: 10, y: 20 }
105
+
106
+ # 条件付き (短縮形)
107
+ - if: condition
108
+ set: { x: 0 }
109
+
110
+ # 条件付き (then/else)
111
+ - if: condition
112
+ then:
113
+ - set: { x: 1 }
114
+ else:
115
+ - set: { x: 0 }
116
+
117
+ # ループ
118
+ - each: items
113
119
  as: item
114
- cond: { gt: [item, 0] }
120
+ index: i
121
+ do:
122
+ - set: { score: { add: [score, item] } }
123
+
124
+ # 配列操作
125
+ - push: { to: arr, item: value }
126
+ - filter:
127
+ list: arr
128
+ as: item
129
+ cond: { gt: [item, 0] }
115
130
  ```
116
131
 
117
- ### Drawing
132
+ ### draw
133
+
134
+ 毎フレームの描画処理を定義する。
118
135
 
119
136
  ```yaml
120
137
  draw:
121
- - cls: # Clear screen
122
- - fill: 10 # Set fill color (0-15)
123
- - stroke: 7 # Set stroke color (0-15)
124
- - noFill: # Disable fill
125
- - noStroke: # Disable stroke
126
- - rect: [x, y, w, h] # Draw rectangle
127
- - print: [text, x, y] # Print text
138
+ - cls: # 画面クリア
139
+ - fill: 10 # 塗りつぶし色 (0-15)
140
+ - stroke: 7 # 線の色 (0-15)
141
+ - noFill: # 塗りつぶし無効
142
+ - noStroke: # 線無効
143
+ - rect: [x, y, w, h] # 矩形
144
+ - circ: [x, y, r] #
145
+ - print: [text, x, y] # テキスト
128
146
  ```
129
147
 
130
- ### Colors (0-15)
131
-
132
- | Index | Color |
133
- |-------|-------|
134
- | 0 | Black |
135
- | 1 | Dark Blue |
136
- | 2 | Dark Green |
137
- | 3 | Dark Cyan |
138
- | 4 | Dark Red |
139
- | 5 | Dark Magenta |
140
- | 6 | Brown |
141
- | 7 | Light Gray |
142
- | 8 | Dark Gray |
143
- | 9 | Blue |
144
- | 10 | Green |
145
- | 11 | Cyan |
146
- | 12 | Red |
147
- | 13 | Magenta |
148
- | 14 | Yellow |
149
- | 15 | White |
148
+ ### Expressions
149
+
150
+ 式は `{ operator: [args] }` の形式で記述する。
151
+
152
+ | Expression | Description |
153
+ |------------|-------------|
154
+ | `{ add: [a, b] }` | 加算 |
155
+ | `{ sub: [a, b] }` | 減算 |
156
+ | `{ mul: [a, b] }` | 乗算 |
157
+ | `{ div: [a, b] }` | 除算 |
158
+ | `{ mod: [a, b] }` | 剰余 |
159
+ | `{ min: [a, b] }` | 最小値 |
160
+ | `{ max: [a, b] }` | 最大値 |
161
+ | `{ rnd: [min, max] }` | 乱数 (整数) |
162
+ | `{ abs: n }` | 絶対値 |
163
+ | `{ floor: n }` | 切り捨て |
164
+ | `{ eq: [a, b] }` | 等価 (0 or 1) |
165
+ | `{ lt: [a, b] }` | 小なり |
166
+ | `{ gt: [a, b] }` | 大なり |
167
+ | `{ and: [a, b, ...] }` | 論理 AND |
168
+ | `{ or: [a, b, ...] }` | 論理 OR |
169
+ | `{ not: a }` | 論理 NOT |
170
+ | `{ at: [arr, i] }` | 配列アクセス |
171
+ | `{ len: arr }` | 配列の長さ |
150
172
 
151
173
  ### Input
152
174
 
175
+ 入力状態は組み込み変数で参照する。
176
+
153
177
  | Variable | Description |
154
178
  |----------|-------------|
155
- | `btn.left` | Left arrow held |
156
- | `btn.right` | Right arrow held |
157
- | `btn.up` | Up arrow held |
158
- | `btn.down` | Down arrow held |
159
- | `btn.a` | Z key held |
160
- | `btn.b` | X key held |
161
- | `btnPressed.left` | Left arrow just pressed |
162
- | `btnPressed.right` | Right arrow just pressed |
163
- | `btnPressed.up` | Up arrow just pressed |
164
- | `btnPressed.down` | Down arrow just pressed |
165
- | `btnPressed.a` | Z key just pressed |
166
- | `btnPressed.b` | X key just pressed |
179
+ | `btn.left` | 左キー押下中 |
180
+ | `btn.right` | 右キー押下中 |
181
+ | `btn.up` | 上キー押下中 |
182
+ | `btn.down` | 下キー押下中 |
183
+ | `btn.a` | Z キー押下中 |
184
+ | `btn.b` | X キー押下中 |
185
+ | `btnPressed.left` | 左キー押した瞬間 |
186
+ | `btnPressed.right` | 右キー押した瞬間 |
187
+ | `btnPressed.up` | 上キー押した瞬間 |
188
+ | `btnPressed.down` | 下キー押した瞬間 |
189
+ | `btnPressed.a` | Z キー押した瞬間 |
190
+ | `btnPressed.b` | X キー押した瞬間 |
167
191
 
168
192
  ## Editor
169
193
 
170
- The TUI console includes a built-in editor with tabs:
194
+ TUI コンソールにはエディタが内蔵されている。
171
195
 
172
196
  | Tab | Description |
173
197
  |-----|-------------|
174
- | CODE | Edit YAML source |
175
- | SPRITE | 16x8 ASCII sprites |
176
- | MAP | 16x16 tile map |
177
- | SFX | Sound effects |
178
- | TRACKER | 4-channel music tracker |
179
- | PLAY | Preview game |
180
- | DATA | Save data |
181
- | QUIT | Exit editor |
198
+ | CODE | YAML ソース編集 |
199
+ | SPRITE | (未実装) |
200
+ | MAP | (未実装) |
201
+ | SFX | 効果音エディタ |
202
+ | TRACKER | 4ch 音楽トラッカー |
203
+ | PLAY | ゲームプレビュー |
204
+ | DATA | セーブデータ |
205
+ | QUIT | エディタ終了 |
182
206
 
183
207
  ## License
184
208
 
package/carts/snake.yaml CHANGED
@@ -188,7 +188,7 @@ update:
188
188
  wave: noi
189
189
  freq: 200
190
190
  length: 0.3
191
- volume: 40
191
+ volume: 3
192
192
  - if:
193
193
  and:
194
194
  - eq:
@@ -220,7 +220,7 @@ update:
220
220
  wave: tri
221
221
  freq: 1200
222
222
  length: 0.08
223
- volume: 15
223
+ volume: 1
224
224
  effect: pitchDown
225
225
  - if:
226
226
  not: ate
@@ -290,3 +290,6 @@ draw:
290
290
  - Press Z to restart
291
291
  - 30
292
292
  - 12
293
+ sfx:
294
+ "0":
295
+ volume: 4
package/carts/wave.yaml CHANGED
@@ -29,7 +29,7 @@ update:
29
29
  wave: sin
30
30
  freq: { add: [200, { mul: [100, { sin: t }] }] }
31
31
  length: 0.2
32
- volume: 50
32
+ volume: 4
33
33
 
34
34
  draw:
35
35
  - fill: 0