Initial site mode stuff

This commit is contained in:
Pyrex 2023-09-22 18:35:47 -07:00
parent 8273243db9
commit 76e92a2a50
8 changed files with 143 additions and 76 deletions

View File

@ -1,11 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class Palette { class Palette {
static const defaultBg = Colors.black; static const defaultBg = Color(0xFF272D1B);
static const defaultFg = Colors.white; static const uiBg = Color(0xFF847A4B);
static const defaultFg = Color(0xFFEEE9D1);
static const demoPlayer = Color(0xFFFEFEF2);
static const subtitle = Colors.red; static const demoDoor = Color(0xFF847A4B);
static const demoExit = Color(0xFF847A4B);
static const demoDoor = Colors.red;
static const demoExit = Colors.red;
} }

73
lib/game/game.dart Normal file
View File

@ -0,0 +1,73 @@
import 'dart:math' as math;
import 'package:dartterm/assets.dart';
import 'package:dartterm/game/sitemode/sitemode.dart';
import 'package:dartterm/gen/generator.dart';
import 'package:dartterm/skreek.dart';
import 'package:dartterm/terminal.dart';
import 'package:dartterm/world/level.dart';
void main() async {
var level = await getLevel();
await sitemode(level);
}
/*
void main() async {
var descriptor = "generic";
while (true) {
at(0, 0).clear();
at(0, 0).puts("Hello, bats!");
at(0, 2).fg(Palette.subtitle).small().puts("Beware of the bat!");
at(4, 4)
.bg(Palette.subtitle)
.fg(Palette.defaultBg)
.big()
.highlight()
.act(Act(
isDefault: true,
label: "Strong!",
callback: () async {
log("strong!");
descriptor = "strong";
}))
.act(Act(
label: "Nocturnal!",
callback: () async {
log("nocturnal!");
descriptor = "nocturnal";
}))
.puts("ALTER BAT");
at(4, 8).normal().puts("A $descriptor bat!");
// await zzz(1.0);
await waitMenu();
}
}
*/
Future<Level> getLevel() async {
Vaults vaults;
while (true) {
Vaults? maybeVaults =
getVaultsIfAvailable("assets/images/vaults/house1.png");
if (maybeVaults != null) {
skreek("wasn't null!");
vaults = maybeVaults;
break;
}
await zzz(0.1);
}
return Generator(math.Random(0), vaults).generateLevel(Requirement(
16,
32,
16,
18,
DirectionSet({
Direction.up,
Direction.down,
Direction.left,
Direction.right,
})));
}

View File

@ -8,7 +8,7 @@ import 'package:dartterm/skreek.dart';
import 'package:dartterm/terminal.dart'; import 'package:dartterm/terminal.dart';
import 'package:dartterm/world/level.dart'; import 'package:dartterm/world/level.dart';
void main() async { void generator_test_program() async {
Vaults vaults; Vaults vaults;
while (true) { while (true) {
skreek("about to load template"); skreek("about to load template");
@ -63,6 +63,10 @@ void main() async {
} }
} }
} }
at(output.spawn.x * 2, output.spawn.y * 2)
.fg(Palette.demoPlayer)
.big()
.puts("\u00ff");
inpLoop: inpLoop:
await for (var inp in rawInput()) { await for (var inp in rawInput()) {
skreek("$inp $seed"); skreek("$inp $seed");
@ -78,37 +82,3 @@ void main() async {
} }
} }
} }
/*
void main() async {
var descriptor = "generic";
while (true) {
at(0, 0).clear();
at(0, 0).puts("Hello, bats!");
at(0, 2).fg(Palette.subtitle).small().puts("Beware of the bat!");
at(4, 4)
.bg(Palette.subtitle)
.fg(Palette.defaultBg)
.big()
.highlight()
.act(Act(
isDefault: true,
label: "Strong!",
callback: () async {
log("strong!");
descriptor = "strong";
}))
.act(Act(
label: "Nocturnal!",
callback: () async {
log("nocturnal!");
descriptor = "nocturnal";
}))
.puts("ALTER BAT");
at(4, 8).normal().puts("A $descriptor bat!");
// await zzz(1.0);
await waitMenu();
}
}
*/

View File

@ -0,0 +1,23 @@
import 'package:dartterm/algorithms/geometry.dart' as geo;
import 'package:dartterm/terminal.dart';
import 'package:dartterm/world/level.dart';
Future<void> sitemode(Level level) async {
await _SiteMode(level).start();
}
class _SiteMode {
Level level;
late geo.Offset position;
_SiteMode(this.level) {
position = level.spawn;
}
Future<void> start() async {
while (true) {
at(0, 0).puts("Site mode!");
await zzz(0.1);
}
}
}

View File

@ -0,0 +1,34 @@
/*
void main() async {
var descriptor = "generic";
while (true) {
at(0, 0).clear();
at(0, 0).puts("Hello, bats!");
at(0, 2).fg(Palette.subtitle).small().puts("Beware of the bat!");
at(4, 4)
.bg(Palette.subtitle)
.fg(Palette.defaultBg)
.big()
.highlight()
.act(Act(
isDefault: true,
label: "Strong!",
callback: () async {
log("strong!");
descriptor = "strong";
}))
.act(Act(
label: "Nocturnal!",
callback: () async {
log("nocturnal!");
descriptor = "nocturnal";
}))
.puts("ALTER BAT");
at(4, 8).normal().puts("A $descriptor bat!");
// await zzz(1.0);
await waitMenu();
}
}
*/

View File

@ -12,6 +12,7 @@ part 'direction_set.dart';
part 'orientation.dart'; part 'orientation.dart';
part 'requirement.dart'; part 'requirement.dart';
part 'vault.dart'; part 'vault.dart';
part 'vault_tile.dart';
part 'vaults.dart'; part 'vaults.dart';
const vaultTries = 30; const vaultTries = 30;

View File

@ -39,37 +39,3 @@ class Vault {
return Vault(tiles.rotateLeft(), smooth.rotateLeft()); return Vault(tiles.rotateLeft(), smooth.rotateLeft());
} }
} }
VaultTile mergeVaultTile(VaultTile bottom, VaultTile top) {
if (bottom == VaultTile.wall && top == VaultTile.archpronewall) {
return VaultTile.wall;
}
if (bottom == VaultTile.wall && top == VaultTile.archwall) {
return VaultTile.wall;
}
if (bottom == VaultTile.archwall && top == VaultTile.archpronewall) {
return VaultTile.archwall;
}
return top;
}
LevelTile flattenVaultTile(VaultTile vt) {
switch (vt) {
case VaultTile.meta0:
case VaultTile.defaultwall:
case VaultTile.archpronewall:
case VaultTile.archwall:
case VaultTile.wall:
return LevelTile.wall;
case VaultTile.exit:
return LevelTile.exit;
case VaultTile.door:
return LevelTile.closedDoor;
case VaultTile.doorpronefloor:
case VaultTile.bspfloor:
case VaultTile.floor:
return LevelTile.floor;
}
}

View File

@ -1,6 +1,6 @@
import 'package:dartterm/colors.dart'; import 'package:dartterm/colors.dart';
import 'package:dartterm/input.dart' as input; import 'package:dartterm/input.dart' as input;
import 'package:dartterm/game.dart' as game; import 'package:dartterm/game/game.dart' as game;
import 'package:dartterm/terminal.dart' as terminal; import 'package:dartterm/terminal.dart' as terminal;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';