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