Sleep with the zzz() function

This commit is contained in:
Pyrex 2023-09-10 15:29:51 -07:00
parent fe89f4e0af
commit 969089eee5
4 changed files with 15 additions and 3 deletions

View File

@ -4,5 +4,5 @@ class Palette {
static const defaultBg = Colors.black; static const defaultBg = Colors.black;
static const defaultFg = Colors.white; static const defaultFg = Colors.white;
static const subtitle = Colors.yellow; static const subtitle = Colors.red;
} }

View File

@ -8,5 +8,13 @@ void main() async {
.bg(Palette.subtitle) .bg(Palette.subtitle)
.fg(Palette.defaultBg) .fg(Palette.defaultBg)
.big() .big()
.puts("BEWARE OF THE BAT!\nA cool bat."); .puts("BEWARE OF THE BAT!\nA cool bat!");
await zzz(1.0);
at(4, 8)
.bg(Palette.subtitle)
.fg(Palette.defaultBg)
.big()
.puts("A strong bat!");
} }

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
void main() { void main() {
game.main();
runApp(const App()); runApp(const App());
} }
@ -44,7 +45,6 @@ class _ViewerState extends State<Viewer> {
ticker = Ticker(tick); ticker = Ticker(tick);
ticker!.start(); ticker!.start();
input.startListening(); input.startListening();
game.main();
} }
@override @override

View File

@ -247,3 +247,7 @@ void clear() {
Cursor at(int x, int y) { Cursor at(int x, int y) {
return Cursor(t: _terminal, x: x, y: y); return Cursor(t: _terminal, x: x, y: y);
} }
Future<void> zzz(double t) async {
await Future.delayed(Duration(milliseconds: (t * 1000).toInt()));
}