diff options
Diffstat (limited to 'lib/level.dart')
-rw-r--r-- | lib/level.dart | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/level.dart b/lib/level.dart index a6d4967..aa042f4 100644 --- a/lib/level.dart +++ b/lib/level.dart @@ -78,8 +78,10 @@ class _LevelState extends State<Level> { setState(() => _position = p); for (final note in notes) { note.position = note.time - p.inMilliseconds / 60000.0; - - if (!note.wasHit && note.position.abs() < 0.5 * 1.0 / 60.0) { + if (note.wasHit != null) { + continue; + } + if (note.position.abs() < 0.5 * 1.0 / 60.0) { bool keypressCorrect = false; switch (note.direction) { case ArrowDirection.up: @@ -101,11 +103,20 @@ class _LevelState extends State<Level> { ScaffoldMessenger.of(context).showSnackBar( SnackBar( - content: Text('This is a toast message'), - duration: Duration(seconds: 2), + content: Text('Great!'), + duration: Duration(milliseconds: 500), ), ); } + } else if (note.position < -0.5 * 1.0 / 60.0) { + print("Missed"); + note.wasHit = false; + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text('Missed!'), + duration: Duration(milliseconds: 500), + ), + ); } } }); |