diff options
| author | Mica White <botahamec@outlook.com> | 2026-10-31 12:38:00 -0400 |
|---|---|---|
| committer | Mica White <botahamec@outlook.com> | 2026-10-31 12:38:00 -0400 |
| commit | 3b39c7561ec71dadb0cb03a153550e9a6e2cddff (patch) | |
| tree | c4d5dd4b4314371a818053c4c6741209967089b3 /src/update_high_score.rs | |
| parent | 2987e310e8e6eaeaa60546bb92a61d9c3713263a (diff) | |
Diffstat (limited to 'src/update_high_score.rs')
| -rw-r--r-- | src/update_high_score.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/update_high_score.rs b/src/update_high_score.rs new file mode 100644 index 0000000..b38b08a --- /dev/null +++ b/src/update_high_score.rs @@ -0,0 +1,14 @@ +use tortuise_script::TortuiseScript; + +use crate::{SAVE_DATA, SNAKE_CELLS}; + +pub const UPDATE_HIGH_SCORE: TortuiseScript = TortuiseScript { + update: |mut context| { + let score = SNAKE_CELLS.get(&context).len() - 2; + let mut save = SAVE_DATA.load_mut(&mut context); + if save.high_score < score { + save.high_score = score; + } + }, + ..TortuiseScript::empty() +}; |
