dartterm/lib/game/sitemode/sitemode.dart

66 lines
1.3 KiB
Dart
Raw Normal View History

2023-09-23 04:08:03 +00:00
import 'package:dartterm/algorithms/dijkstra.dart';
2023-09-23 01:35:47 +00:00
import 'package:dartterm/algorithms/geometry.dart' as geo;
2023-09-23 04:08:03 +00:00
import 'package:dartterm/algorithms/shadowcasting.dart';
import 'package:dartterm/colors.dart';
import 'package:dartterm/skreek.dart';
2023-09-23 01:35:47 +00:00
import 'package:dartterm/terminal.dart';
import 'package:dartterm/world/level.dart';
2023-09-23 04:08:03 +00:00
import 'dart:math' as math;
part 'camera.dart';
part 'player.dart';
part 'fov.dart';
2023-09-23 01:35:47 +00:00
Future<void> sitemode(Level level) async {
2023-09-23 04:08:03 +00:00
await SiteMode(level).start();
2023-09-23 01:35:47 +00:00
}
2023-09-23 04:08:03 +00:00
class SiteMode {
2023-09-23 01:35:47 +00:00
Level level;
2023-09-23 04:08:03 +00:00
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();
}
2023-09-23 01:35:47 +00:00
2023-09-23 04:08:03 +00:00
void init() {
cameraInit();
}
void maintain() {
playerMaintain();
fovMaintain();
cameraMaintain();
}
void draw() {
clear();
cameraDraw();
2023-09-23 01:35:47 +00:00
}
Future<void> start() async {
while (true) {
2023-09-23 04:08:03 +00:00
maintain();
draw();
// take automated actions, otherwise receive input
if (playerTookAutomatedAction) {
await zzz(0.1);
} else {
await waitMenu();
}
2023-09-23 01:35:47 +00:00
}
}
}