First remotely working WFC

This commit is contained in:
2023-09-19 19:19:26 -07:00
parent 49027d74fe
commit bc6a7cd5a7
8 changed files with 600 additions and 144 deletions

View File

@ -1,5 +1,33 @@
import 'dart:ui';
import 'package:dartterm/wfc/template.dart';
enum LevelTile {
exit,
door,
floor,
wall,
}
class Level {
Set<(int, int)> openCells = {};
}
Future<WfcTemplate<LevelTile>> loadLevelWfcAsync(String name) async {
return WfcTemplate.loadAsync(name, 2, (c) {
switch (c) {
// ABGR
case 0xFF000000:
case 0xFF707070:
return LevelTile.wall;
case 0xFFFFFFFF:
case 0xFF00FFFF:
case 0xFFFF00FF:
return LevelTile.floor;
case 0xFFFF8700:
return LevelTile.door;
case 0xFF0000FF:
return LevelTile.exit;
default:
throw Exception("unrecognized pixel: $c");
}
});
}