Added colors and textures
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -1,24 +1,29 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:wolf_dart/classes/matrix.dart';
|
||||
import 'package:wolf_dart/features/map/vswap_parser.dart';
|
||||
import 'package:wolf_dart/features/map/wolf_level.dart';
|
||||
import 'package:wolf_dart/features/map/wolf_map_parser.dart';
|
||||
|
||||
class WolfMap {
|
||||
/// The fully parsed and decompressed levels from the game files.
|
||||
final List<WolfLevel> levels;
|
||||
final List<Matrix<int>> textures;
|
||||
|
||||
// A private constructor so we can only instantiate this from the async loader
|
||||
WolfMap._(this.levels);
|
||||
WolfMap._(this.levels, this.textures);
|
||||
|
||||
/// Asynchronously loads the map files and parses them into a new WolfMap instance.
|
||||
static Future<WolfMap> load() async {
|
||||
// 1. Load the binary data
|
||||
final mapHead = await rootBundle.load("assets/MAPHEAD.WL1");
|
||||
final gameMaps = await rootBundle.load("assets/GAMEMAPS.WL1");
|
||||
final vswap = await rootBundle.load("assets/VSWAP.WL1");
|
||||
|
||||
// 2. Parse the data using the parser we just built
|
||||
final parsedLevels = WolfMapParser.parseMaps(mapHead, gameMaps);
|
||||
final parsedTextures = VswapParser.parseWalls(vswap);
|
||||
|
||||
// 3. Return the populated instance!
|
||||
return WolfMap._(parsedLevels);
|
||||
return WolfMap._(parsedLevels, parsedTextures);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user