feat: complete Style 32 overhaul & Tiled integration fix
- Enforced 'Style 32 - Dark Chibi Vector' for all ground assets. - Fixed critical Prologue-to-Game crash (function renaming). - Implemented Tiled JSON/TMX auto-conversion. - Updated Asset Manager to visualize 1800+ assets. - Cleaned up project structure (new assets/grounds folder). - Auto-Ground logic added to GameScene.js.
This commit is contained in:
79
tools/create_tmx.js
Normal file
79
tools/create_tmx.js
Normal file
@@ -0,0 +1,79 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const TILED_DIR = path.join(__dirname, '../assets/tiled');
|
||||
const ASSETS_ROOT = path.join(__dirname, '../assets');
|
||||
|
||||
// Configuration
|
||||
const TMX_FILENAME = 'Faza1_Nova.tmx';
|
||||
const TSX_FILENAME = 'Buildings.tsx';
|
||||
const MAP_WIDTH = 80;
|
||||
const MAP_HEIGHT = 80;
|
||||
|
||||
// Gather all images
|
||||
const imageFiles = [];
|
||||
const sourceDirs = ['buildings', 'terrain', 'props'];
|
||||
|
||||
let tileIdCounter = 0;
|
||||
let tilesXml = '';
|
||||
|
||||
sourceDirs.forEach(dirName => {
|
||||
const fullPath = path.join(ASSETS_ROOT, dirName);
|
||||
if (fs.existsSync(fullPath)) {
|
||||
const files = fs.readdirSync(fullPath);
|
||||
files.forEach(file => {
|
||||
if (file.toLowerCase().endsWith('.png')) {
|
||||
// Determine relative path from assets/tiled/ to assets/dir/file
|
||||
// assets/tiled -> assets/dir = ../dir
|
||||
const relativePath = `../${dirName}/${file}`;
|
||||
|
||||
tilesXml += ` <tile id="${tileIdCounter}">\n`;
|
||||
tilesXml += ` <image source="${relativePath}"/>\n`; // Let Tiled detect size
|
||||
tilesXml += ` </tile>\n`;
|
||||
|
||||
tileIdCounter++;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 1. Generate TSX (Tileset)
|
||||
const tsxContent = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<tileset version="1.10" tiledversion="1.11.0" name="Buildings" tilewidth="256" tileheight="256" tilecount="${tileIdCounter}" columns="0">
|
||||
<grid orientation="orthogonal" width="1" height="1"/>
|
||||
${tilesXml}
|
||||
</tileset>`;
|
||||
|
||||
fs.writeFileSync(path.join(TILED_DIR, TSX_FILENAME), tsxContent);
|
||||
console.log(`✅ Created tileset: ${TSX_FILENAME} with ${tileIdCounter} tiles.`);
|
||||
|
||||
// 2. Generate TMX (Map)
|
||||
// Create empty CSV data (all zeros)
|
||||
const csvData = new Array(MAP_WIDTH * MAP_HEIGHT).fill(0).join(',');
|
||||
|
||||
const tmxContent = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.11.0" orientation="orthogonal" renderorder="right-down" width="${MAP_WIDTH}" height="${MAP_HEIGHT}" tilewidth="48" tileheight="48" infinite="0" nextlayerid="5" nextobjectid="1">
|
||||
<properties>
|
||||
<property name="music" value="farm_theme"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="${TSX_FILENAME}"/>
|
||||
<layer id="1" name="Ground" width="${MAP_WIDTH}" height="${MAP_HEIGHT}">
|
||||
<data encoding="csv">
|
||||
${csvData}
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="2" name="Objects" width="${MAP_WIDTH}" height="${MAP_HEIGHT}">
|
||||
<data encoding="csv">
|
||||
${csvData}
|
||||
</data>
|
||||
</layer>
|
||||
<layer id="3" name="Collision" width="${MAP_WIDTH}" height="${MAP_HEIGHT}" opacity="0.5">
|
||||
<data encoding="csv">
|
||||
${csvData}
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup id="4" name="Audio_Zones"/>
|
||||
</map>`;
|
||||
|
||||
fs.writeFileSync(path.join(TILED_DIR, TMX_FILENAME), tmxContent);
|
||||
console.log(`✅ Created map: ${TMX_FILENAME} (${MAP_WIDTH}x${MAP_HEIGHT}) linked to ${TSX_FILENAME}.`);
|
||||
Reference in New Issue
Block a user