From f01d3bff36adf538360e58b018fcf763592a2fa5 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Mon, 7 Mar 2022 22:56:05 +0000 Subject: [PATCH] Use saturating_sub rather than regular subtraction --- examples/the-purple-night/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/the-purple-night/src/main.rs b/examples/the-purple-night/src/main.rs index 59640239..047eb541 100644 --- a/examples/the-purple-night/src/main.rs +++ b/examples/the-purple-night/src/main.rs @@ -393,10 +393,10 @@ impl SwordState { } fn attack_frame(self, timer: u16) -> u16 { match self { - SwordState::LongSword => (self.attack_duration() - timer) / 8, - SwordState::ShortSword => (self.attack_duration() - timer) / 8, - SwordState::Dagger => (self.attack_duration() - timer) / 8, - SwordState::Swordless => (self.attack_duration() - timer) / 8, + SwordState::LongSword => (self.attack_duration().saturating_sub(timer)) / 8, + SwordState::ShortSword => (self.attack_duration().saturating_sub(timer)) / 8, + SwordState::Dagger => (self.attack_duration().saturating_sub(timer)) / 8, + SwordState::Swordless => (self.attack_duration().saturating_sub(timer)) / 8, } } fn jump_attack_tag(self) -> &'static Tag {