diff options
Diffstat (limited to 'lib/screens/level.dart')
-rw-r--r-- | lib/screens/level.dart | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/screens/level.dart b/lib/screens/level.dart index 9c5823b..a22c237 100644 --- a/lib/screens/level.dart +++ b/lib/screens/level.dart @@ -87,6 +87,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin { } }); + // go to GameOverStats when level finishes player.onPlayerComplete.listen((void _) { Route route = MaterialPageRoute( builder: (context) => GameOverStats( @@ -105,6 +106,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin { }); } + // convert beats to notes widget.simfile.chartSimplest?.beats.forEach((time, noteData) { int arrowIndex = noteData.indexOf('1'); if (arrowIndex < 0 || arrowIndex > 3) { @@ -126,6 +128,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin { super.dispose(); } + /// toggle between pause and resume void _pauseResume() { if (_isPlaying) { player.pause(); @@ -140,18 +143,24 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin { } } + /// checks if the [note] is hit on [time] with the correct InputDirection void _noteHitCheck(Note note, Duration time) { note.position = note.time - time.inMilliseconds / 60000.0; if (note.wasHit != null) { return; } + + // you have +- half a second to hit if (note.position.abs() < 0.5 * 1.0 / 60.0) { + // combine keyboard and esense input InputDirection esenseDirection = ESenseInput.instance.getInputDirection(note.direction); inputDirection.up |= esenseDirection.up; inputDirection.down |= esenseDirection.down; inputDirection.left |= esenseDirection.left; inputDirection.right |= esenseDirection.right; + + // check if input matches arrow direction bool keypressCorrect = false; switch (note.direction) { case ArrowDirection.up: @@ -189,6 +198,7 @@ class _LevelState extends State<Level> with SingleTickerProviderStateMixin { } } + /// sets the InputDirection based on the arrow keys void _keyboardHandler(event) { bool isDown = false; if (event is KeyDownEvent) { |