Fixed ASCII and cli rendering
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -41,6 +41,13 @@ void main() async {
|
||||
final input = CliInput();
|
||||
final cliAudio = CliSilentAudio();
|
||||
|
||||
final rasterizer = AsciiRasterizer();
|
||||
|
||||
FrameBuffer buffer = FrameBuffer(
|
||||
stdout.terminalColumns,
|
||||
stdout.terminalLines,
|
||||
);
|
||||
|
||||
final engine = WolfEngine(
|
||||
data: data,
|
||||
difficulty: Difficulty.bringEmOn,
|
||||
@@ -52,9 +59,6 @@ void main() async {
|
||||
},
|
||||
);
|
||||
|
||||
final rasterizer = AsciiRasterizer();
|
||||
final buffer = FrameBuffer(120, 40);
|
||||
|
||||
engine.init();
|
||||
|
||||
stdin.listen((List<int> bytes) {
|
||||
@@ -70,7 +74,9 @@ void main() async {
|
||||
Timer.periodic(const Duration(milliseconds: 33), (timer) {
|
||||
// 1. Terminal Size Safety Check
|
||||
if (stdout.hasTerminal) {
|
||||
if (stdout.terminalColumns < 120 || stdout.terminalLines < 40) {
|
||||
int cols = stdout.terminalColumns;
|
||||
int rows = stdout.terminalLines;
|
||||
if (cols < 80 || rows < 24) {
|
||||
// Clear the screen and print the warning at the top left
|
||||
stdout.write('\x1b[2J\x1b[H');
|
||||
stdout.write('\x1b[31m[ ERROR ] TERMINAL TOO SMALL\x1b[0m\n\n');
|
||||
@@ -86,6 +92,10 @@ void main() async {
|
||||
lastTick = stopwatch.elapsed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer.width != cols || buffer.height != rows) {
|
||||
buffer = FrameBuffer(cols, rows);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Normal Game Loop
|
||||
|
||||
Reference in New Issue
Block a user