diff options
author | Orangerot <purple@orangerot.dev> | 2025-01-14 17:35:24 +0100 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2025-01-14 17:35:24 +0100 |
commit | e030b60c2567af239b81c9a36c502fa22defdc97 (patch) | |
tree | 83a7b5ac05220714c1deb18d56c9433900ded0ff /lib/screens/level.dart | |
parent | 28d0fe7d8c3a38d7c2ded86c30b549ed6be48f3c (diff) |
feat: add comments
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) { |