@@ -49,34 +49,18 @@ class _WolfRendererState extends State<WolfRenderer>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_initGame();
|
||||
_initGame(demo: widget.isDemo);
|
||||
}
|
||||
|
||||
Future<void> _initGame() async {
|
||||
// 1. Load the entire WAD/WL1 data
|
||||
gameMap = await WolfMap.load();
|
||||
Future<void> _initGame({bool demo = true}) async {
|
||||
// 1. Load the entire WL1 (demo)/WL6 (retail) data
|
||||
gameMap = demo ? await WolfMap.loadDemo() : await WolfMap.load();
|
||||
|
||||
// 2. Extract Level 1 (E1M1)
|
||||
currentLevel = gameMap.levels[0].wallGrid;
|
||||
|
||||
final Matrix<int> objectLevel = gameMap.levels[0].objectGrid;
|
||||
|
||||
// Adjusted mapping for WL1 Shareware
|
||||
// These numbers represent the delta from the FIRST sprite chunk in VSWAP
|
||||
Map<int, int> staticObjects = {
|
||||
23: widget.isDemo ? 0 : 23, // Water Puddle
|
||||
24: widget.isDemo ? 1 : 24, // Green Barrel
|
||||
25: widget.isDemo ? 2 : 25, // Chairs
|
||||
26: widget.isDemo ? 3 : 26, // Green Plant
|
||||
27: widget.isDemo ? 4 : 27, // Skeleton / Bones
|
||||
28: widget.isDemo ? 5 : 28, // Blue Lamp
|
||||
29: widget.isDemo ? 6 : 29, // Chandelier
|
||||
30: widget.isDemo ? 7 : 30, // Dog food
|
||||
31: widget.isDemo ? 8 : 31, // White pillar
|
||||
32: widget.isDemo ? 9 : 32, // Hanged man
|
||||
50: widget.isDemo ? 42 : 95, // Standing Guard (Front-facing frame)
|
||||
};
|
||||
|
||||
// 1. SCAN FOR PLAYER SPAWN & ENTITIES
|
||||
for (int y = 0; y < 64; y++) {
|
||||
for (int x = 0; x < 64; x++) {
|
||||
@@ -97,12 +81,26 @@ class _WolfRendererState extends State<WolfRenderer>
|
||||
}
|
||||
}
|
||||
// NEW: Populate the Entities!
|
||||
else if (staticObjects.containsKey(objId)) {
|
||||
entities.add((
|
||||
x: x + 0.5,
|
||||
y: y + 0.5,
|
||||
spriteIndex: staticObjects[objId]!,
|
||||
));
|
||||
else if (objId >= 23 && objId <= 70) {
|
||||
int calculatedSpriteIndex = objId - 21;
|
||||
|
||||
// Safety bounds check to prevent crashes on custom/corrupt maps
|
||||
if (calculatedSpriteIndex >= 0 &&
|
||||
calculatedSpriteIndex < gameMap.sprites.length) {
|
||||
entities.add((
|
||||
x: x + 0.5,
|
||||
y: y + 0.5,
|
||||
spriteIndex: calculatedSpriteIndex,
|
||||
));
|
||||
}
|
||||
} else if (objId == 124) {
|
||||
if (95 < gameMap.sprites.length) {
|
||||
entities.add((
|
||||
x: x + 0.5,
|
||||
y: y + 0.5,
|
||||
spriteIndex: 95,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user