Fixed color palette and player starting location

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-13 17:05:15 +01:00
parent 464a22e1f3
commit 0c3ca1c090
5 changed files with 207 additions and 119 deletions

View File

@@ -5,11 +5,13 @@ class WolfLevel {
final int width; // Always 64 in standard Wolf3D
final int height; // Always 64
final Matrix<int> wallGrid;
final Matrix<int> objectGrid;
WolfLevel({
required this.name,
required this.width,
required this.height,
required this.wallGrid,
required this.objectGrid,
});
}

View File

@@ -48,27 +48,36 @@ abstract class WolfMapParser {
}
String name = ascii.decode(nameBytes);
// 3. EXTRACT AND DECOMPRESS THE WALL DATA
// 3. EXTRACT AND DECOMPRESS BOTH PLANES
// --- PLANE 0: WALLS ---
final compressedWallData = gameMaps.buffer.asUint8List(
plane0Offset,
plane0Length,
);
Uint16List carmackExpandedWalls = _expandCarmack(compressedWallData);
List<int> flatWallGrid = _expandRlew(carmackExpandedWalls, rlewTag);
// 1st Pass: Un-Carmack
Uint16List carmackExpanded = _expandCarmack(compressedWallData);
// 2nd Pass: Un-RLEW
List<int> flatGrid = _expandRlew(carmackExpanded, rlewTag);
// --- PLANE 1: OBJECTS (NEW) ---
final compressedObjectData = gameMaps.buffer.asUint8List(
plane1Offset,
plane1Length,
);
Uint16List carmackExpandedObjects = _expandCarmack(compressedObjectData);
List<int> flatObjectGrid = _expandRlew(carmackExpandedObjects, rlewTag);
// Convert the flat List<int> (4096 items) into a Matrix<int> (64x64 grid)
Matrix<int> wallGrid = [];
Matrix<int> objectGrid = []; // NEW
for (int y = 0; y < height; y++) {
List<int> row = [];
List<int> wallRow = [];
List<int> objectRow = []; // NEW
for (int x = 0; x < width; x++) {
// Note: In original Wolf3D, empty space is usually ID 90 or 106,
// but we can map them down to 0 for your raycaster logic later.
row.add(flatGrid[y * width + x]);
wallRow.add(flatWallGrid[y * width + x]);
objectRow.add(flatObjectGrid[y * width + x]); // NEW
}
wallGrid.add(row);
wallGrid.add(wallRow);
objectGrid.add(objectRow); // NEW
}
levels.add(
@@ -76,7 +85,8 @@ abstract class WolfMapParser {
name: name,
width: width,
height: height,
wallGrid: wallGrid, // Pass the fully decompressed matrix!
wallGrid: wallGrid,
objectGrid: objectGrid,
),
);
}