import 'dart:math' as math; import 'package:dartterm/assets.dart'; import 'package:dartterm/algorithms/geometry.dart' as geo; import 'package:dartterm/colors.dart'; import 'package:dartterm/gen/generator.dart'; import 'package:dartterm/input.dart'; import 'package:dartterm/skreek.dart'; import 'package:dartterm/terminal.dart'; import 'package:dartterm/world/level.dart'; void generator_test_program() async { Vaults vaults; while (true) { skreek("about to load template"); at(0, 0).clear(); at(0, 0).puts("Loading template!"); Vaults? maybeVaults = getVaultsIfAvailable("assets/images/vaults/house1.png"); if (maybeVaults != null) { skreek("wasn't null!"); vaults = maybeVaults; break; } await zzz(0.1); } at(0, 0).clear(); at(0, 0).puts("Loaded! $vaults"); int seed = 0; while (true) { clear(); Level output = Generator(math.Random(seed), vaults).generateLevel(Requirement( 16, 32, 16, 18, DirectionSet({ Direction.up, Direction.down, Direction.left, Direction.right, }))); var geo.Size(dx: w, dy: h) = output.size; for (var y = 0; y < h; y++) { for (var x = 0; x < w; x++) { var cursor = at(x * 2, y * 2).big(); switch (output.tiles.get(x, y)) { case LevelTile.floor: case LevelTile.openDoor: cursor.puts(" "); case LevelTile.closedDoor: cursor.fg(Palette.demoDoor).puts("+"); case LevelTile.exit: cursor.fg(Palette.demoExit).puts("X"); case LevelTile.wall: cursor.puts("#"); case null: cursor.puts("?"); } } } at(output.spawn.x * 2, output.spawn.y * 2) .fg(Palette.demoPlayer) .big() .puts("\u00ff"); inpLoop: await for (var inp in rawInput()) { skreek("$inp $seed"); switch (inp) { case Keystroke(text: "a"): seed -= 1; break inpLoop; case Keystroke(text: "d"): seed += 1; break inpLoop; default: } } } }