@stephenwil/create-tessera 0.0.0-stage → 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/bin/create-tessera.mjs +229 -0
- package/package.json +23 -4
- package/README.md +0 -3
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
const target = args.find(a => !a.startsWith('-')) || '.';
|
|
11
|
+
const targetDir = path.resolve(process.cwd(), target);
|
|
12
|
+
|
|
13
|
+
const HELP = `
|
|
14
|
+
Usage:
|
|
15
|
+
npm create @stephenwil/tessera <directory>
|
|
16
|
+
npx create-tessera <directory>
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
--help, -h Show help message
|
|
20
|
+
--version, -v Show version
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
24
|
+
console.log(HELP.trim());
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (args.includes('--version') || args.includes('-v')) {
|
|
29
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8'));
|
|
30
|
+
console.log(`create-tessera v${pkg.version}`);
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
console.log(`\nCreating a new Tessera cart project in ${targetDir}...\n`);
|
|
35
|
+
|
|
36
|
+
const projectName = path.basename(targetDir) === '.' ? 'my-cart' : path.basename(targetDir);
|
|
37
|
+
|
|
38
|
+
// 1. Create directory structure
|
|
39
|
+
fs.mkdirSync(path.join(targetDir, 'src'), { recursive: true });
|
|
40
|
+
fs.mkdirSync(path.join(targetDir, 'models'), { recursive: true });
|
|
41
|
+
fs.mkdirSync(path.join(targetDir, 'assets'), { recursive: true });
|
|
42
|
+
fs.mkdirSync(path.join(targetDir, '.vscode'), { recursive: true });
|
|
43
|
+
|
|
44
|
+
// 2. tessera.json manifest
|
|
45
|
+
const manifest = {
|
|
46
|
+
id: projectName.toLowerCase().replace(/[^a-z0-9_-]/g, '-'),
|
|
47
|
+
title: projectName.replace(/[-_]/g, ' ').replace(/\b\w/g, c => c.toUpperCase()),
|
|
48
|
+
author: 'Developer',
|
|
49
|
+
version: '1.0.0',
|
|
50
|
+
description: 'A new game made for the Tessera High-Res voxel fantasy console.',
|
|
51
|
+
lua: [
|
|
52
|
+
'src/main.lua'
|
|
53
|
+
],
|
|
54
|
+
models: {},
|
|
55
|
+
palette: 'assets/palette.txt'
|
|
56
|
+
};
|
|
57
|
+
fs.writeFileSync(path.join(targetDir, 'tessera.json'), JSON.stringify(manifest, null, 2) + '\n');
|
|
58
|
+
|
|
59
|
+
// 3. src/main.lua starter code
|
|
60
|
+
const starterLua = `-- ${manifest.title}
|
|
61
|
+
-- Built for Tessera High-Res Voxel Console (256x256x128 volume, 768x432 HUD)
|
|
62
|
+
|
|
63
|
+
local px, py, pz = 128, 128, 2
|
|
64
|
+
local angle = 0
|
|
65
|
+
|
|
66
|
+
function _init()
|
|
67
|
+
-- Set camera position & look target
|
|
68
|
+
cam(128, 64, 48, 1.2, 0, 30)
|
|
69
|
+
camtarget(128, 128, 10)
|
|
70
|
+
fog(1, 0.002)
|
|
71
|
+
|
|
72
|
+
-- Draw a stone platform on the persistent map layer
|
|
73
|
+
mbox(100, 100, 0, 156, 156, 1, 4)
|
|
74
|
+
mbox(112, 112, 0, 144, 144, 1, 5)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
function _update()
|
|
78
|
+
-- Input handling: Arrow keys / Gamepad D-pad
|
|
79
|
+
local speed = 1.0
|
|
80
|
+
if btn(0) then px = px - speed end
|
|
81
|
+
if btn(1) then px = px + speed end
|
|
82
|
+
if btn(2) then py = py - speed end
|
|
83
|
+
if btn(3) then py = py + speed end
|
|
84
|
+
|
|
85
|
+
-- Clamp inside platform boundary
|
|
86
|
+
px = mid(105, px, 151)
|
|
87
|
+
py = mid(105, py, 151)
|
|
88
|
+
|
|
89
|
+
angle = angle + 0.04
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
function _draw()
|
|
93
|
+
-- Dynamic drawing layer: cls() clears previous frame voxels
|
|
94
|
+
cls(0)
|
|
95
|
+
|
|
96
|
+
-- Draw player avatar sphere
|
|
97
|
+
sphere(px, py, pz + 4, 3, 9)
|
|
98
|
+
|
|
99
|
+
-- Draw rotating orbital particle
|
|
100
|
+
local ox = px + math.cos(angle) * 8
|
|
101
|
+
local oy = py + math.sin(angle) * 8
|
|
102
|
+
vset(ox, oy, pz + 4, 11)
|
|
103
|
+
|
|
104
|
+
-- HUD Canvas Overlay (768x432 resolution)
|
|
105
|
+
rectfill(20, 20, 260, 60, 1)
|
|
106
|
+
rect(20, 20, 260, 60, 7)
|
|
107
|
+
print("${manifest.title}", 32, 28, 7)
|
|
108
|
+
print("Use Arrows / Gamepad to move", 32, 42, 6)
|
|
109
|
+
end
|
|
110
|
+
`;
|
|
111
|
+
fs.writeFileSync(path.join(targetDir, 'src/main.lua'), starterLua);
|
|
112
|
+
|
|
113
|
+
// 4. assets/palette.txt default palette
|
|
114
|
+
const defaultPal = `# Tessera Custom Palette
|
|
115
|
+
# Index: #RRGGBB
|
|
116
|
+
1: #181a20
|
|
117
|
+
2: #282c37
|
|
118
|
+
3: #3f4756
|
|
119
|
+
4: #68748a
|
|
120
|
+
5: #9aa8be
|
|
121
|
+
6: #cad6e2
|
|
122
|
+
7: #f0f4f8
|
|
123
|
+
8: #e64553
|
|
124
|
+
9: #fe640b
|
|
125
|
+
10: #df8e1d
|
|
126
|
+
11: #40a02b
|
|
127
|
+
12: #209fb5
|
|
128
|
+
13: #1e66f5
|
|
129
|
+
14: #8839ef
|
|
130
|
+
15: #ea76cb
|
|
131
|
+
`;
|
|
132
|
+
fs.writeFileSync(path.join(targetDir, 'assets/palette.txt'), defaultPal);
|
|
133
|
+
|
|
134
|
+
// 5. package.json for project scripts
|
|
135
|
+
const projectPkg = {
|
|
136
|
+
name: manifest.id,
|
|
137
|
+
version: '1.0.0',
|
|
138
|
+
private: true,
|
|
139
|
+
type: 'module',
|
|
140
|
+
scripts: {
|
|
141
|
+
dev: 'tessera dev',
|
|
142
|
+
pack: 'tessera pack',
|
|
143
|
+
build: 'tessera pack && tessera export',
|
|
144
|
+
check: 'tessera check'
|
|
145
|
+
},
|
|
146
|
+
devDependencies: {
|
|
147
|
+
'@stephenwil/tessera': '^0.1.0'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(projectPkg, null, 2) + '\n');
|
|
151
|
+
|
|
152
|
+
// 6. VS Code LuaLS settings
|
|
153
|
+
const vscodeSettings = {
|
|
154
|
+
"Lua.runtime.version": "Lua 5.4",
|
|
155
|
+
"Lua.diagnostics.globals": [
|
|
156
|
+
"_init",
|
|
157
|
+
"_update",
|
|
158
|
+
"_draw",
|
|
159
|
+
"vset",
|
|
160
|
+
"vget",
|
|
161
|
+
"box",
|
|
162
|
+
"sphere",
|
|
163
|
+
"line3d",
|
|
164
|
+
"model",
|
|
165
|
+
"particle",
|
|
166
|
+
"mset",
|
|
167
|
+
"mget",
|
|
168
|
+
"mbox",
|
|
169
|
+
"mmodel",
|
|
170
|
+
"mheight",
|
|
171
|
+
"mclear",
|
|
172
|
+
"cam",
|
|
173
|
+
"camtarget",
|
|
174
|
+
"camfov",
|
|
175
|
+
"fog",
|
|
176
|
+
"pal",
|
|
177
|
+
"palt",
|
|
178
|
+
"pswap",
|
|
179
|
+
"cls",
|
|
180
|
+
"rect",
|
|
181
|
+
"rectfill",
|
|
182
|
+
"circfill",
|
|
183
|
+
"spr2d",
|
|
184
|
+
"print",
|
|
185
|
+
"textw",
|
|
186
|
+
"project",
|
|
187
|
+
"raycast3d",
|
|
188
|
+
"check_box",
|
|
189
|
+
"sweep_box",
|
|
190
|
+
"sweep_down",
|
|
191
|
+
"vheight",
|
|
192
|
+
"sfx",
|
|
193
|
+
"music",
|
|
194
|
+
"btn",
|
|
195
|
+
"btnp",
|
|
196
|
+
"t",
|
|
197
|
+
"flr",
|
|
198
|
+
"mid",
|
|
199
|
+
"rnd",
|
|
200
|
+
"noise3",
|
|
201
|
+
"stat",
|
|
202
|
+
"dget",
|
|
203
|
+
"dset"
|
|
204
|
+
]
|
|
205
|
+
};
|
|
206
|
+
fs.writeFileSync(path.join(targetDir, '.vscode/settings.json'), JSON.stringify(vscodeSettings, null, 2) + '\n');
|
|
207
|
+
|
|
208
|
+
// 7. README.md
|
|
209
|
+
const readme = `# ${manifest.title}
|
|
210
|
+
|
|
211
|
+
A game for the [Tessera High-Res](https://github.com/stephenwil/tessera-kit) voxel fantasy console.
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
\`\`\`sh
|
|
216
|
+
# Start live development server
|
|
217
|
+
npm run dev
|
|
218
|
+
|
|
219
|
+
# Build .tess and .tess.png cartridge
|
|
220
|
+
npm run pack
|
|
221
|
+
|
|
222
|
+
# Export offline standalone single-file HTML
|
|
223
|
+
npm run build
|
|
224
|
+
\`\`\`
|
|
225
|
+
`;
|
|
226
|
+
fs.writeFileSync(path.join(targetDir, 'README.md'), readme);
|
|
227
|
+
|
|
228
|
+
console.log(`Success! Project initialized.\n`);
|
|
229
|
+
console.log(`Next steps:\n cd ${path.relative(process.cwd(), targetDir) || '.'}\n npm install\n npm run dev\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stephenwil/create-tessera",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Create a new Tessera High-Res voxel fantasy console cart project",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"create-tessera": "bin/create-tessera.mjs"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"src",
|
|
12
|
+
"template"
|
|
13
|
+
],
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"create-tessera",
|
|
19
|
+
"tessera",
|
|
20
|
+
"scaffolder",
|
|
21
|
+
"gamedev"
|
|
22
|
+
],
|
|
23
|
+
"author": "Stephen Wilson",
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|
package/README.md
DELETED