66 lines
1.3 KiB
Dart
66 lines
1.3 KiB
Dart
import 'package:dartterm/algorithms/dijkstra.dart';
|
|
import 'package:dartterm/algorithms/geometry.dart' as geo;
|
|
import 'package:dartterm/algorithms/shadowcasting.dart';
|
|
import 'package:dartterm/colors.dart';
|
|
import 'package:dartterm/skreek.dart';
|
|
import 'package:dartterm/terminal.dart';
|
|
import 'package:dartterm/world/level.dart';
|
|
import 'dart:math' as math;
|
|
|
|
part 'camera.dart';
|
|
part 'player.dart';
|
|
part 'fov.dart';
|
|
|
|
Future<void> sitemode(Level level) async {
|
|
await SiteMode(level).start();
|
|
}
|
|
|
|
class SiteMode {
|
|
Level level;
|
|
late geo.Offset playerPosition;
|
|
bool playerTookAutomatedAction = false;
|
|
List<geo.Offset> playerIntendedPath = [];
|
|
|
|
late geo.Offset camera;
|
|
|
|
late Set<geo.Offset> fovVisible;
|
|
late Set<geo.Offset> fovMovable;
|
|
Set<geo.Offset> fovMemory = {};
|
|
|
|
SiteMode(this.level) {
|
|
playerPosition = level.spawn;
|
|
|
|
init();
|
|
maintain();
|
|
}
|
|
|
|
void init() {
|
|
cameraInit();
|
|
}
|
|
|
|
void maintain() {
|
|
playerMaintain();
|
|
fovMaintain();
|
|
cameraMaintain();
|
|
}
|
|
|
|
void draw() {
|
|
clear();
|
|
cameraDraw();
|
|
}
|
|
|
|
Future<void> start() async {
|
|
while (true) {
|
|
maintain();
|
|
draw();
|
|
|
|
// take automated actions, otherwise receive input
|
|
if (playerTookAutomatedAction) {
|
|
await zzz(0.1);
|
|
} else {
|
|
await waitMenu();
|
|
}
|
|
}
|
|
}
|
|
}
|