From f969d8382e70a0895745538dd6b47f66463c5a6f Mon Sep 17 00:00:00 2001 From: spatialfree Date: Mon, 25 Nov 2024 23:45:39 -0500 Subject: [PATCH] food next delta bool --- src/Arts.cs | 7 +++---- src/Mono.cs | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Arts.cs b/src/Arts.cs index 3979142..5d9a762 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -151,8 +151,7 @@ static class Arts // snake float snake_t = headmove.state ? Maths.u_clamp(Maths.smooth_stop((float)Mono.step_t) * 3.0f) : 1.0f; - bool food_next = !Mono.eaten_latch.state && (Mono.snake[0] + Mono.snake_dir) == Mono.food; - if (!Mono.menu && !food_next) + if (!Mono.menu && !Mono.food_next.state) { meshes["Tongue"].Draw( mat_mono, @@ -167,7 +166,7 @@ static class Arts string face = "Face0Default"; face = Mono.grow_buffer > 0 ? "Face2Eaten" : face; face = Mono.in_box.delta != 0 ? "Face3Bump" : face; - face = food_next ? "Face1Eat" : face; + face = Mono.food_next.state ? "Face1Eat" : face; meshes[face].Draw( mat_mono, Matrix.TRS( @@ -238,7 +237,7 @@ static class Arts } // food - if (!food_next) + if (!Mono.food_next.state) { food_ori *= Quat.FromAngles( 90 * Time.Stepf, diff --git a/src/Mono.cs b/src/Mono.cs index b19d987..fe8e783 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -42,6 +42,7 @@ static class Mono public static XYZi food = new(0, 0, 0); // [!] start random to keep new game fresh? public static int eaten = 0; public static DeltaBool eaten_latch = new(false); + public static DeltaBool food_next = new(false); public static double eat_timestamp = 0.0; public enum BoxMode @@ -127,6 +128,8 @@ static class Mono { snake_dir = Rig.new_dir; } + + food_next.Step(!Mono.eaten_latch.state && (Mono.snake[0] + Mono.snake_dir) == Mono.food); } public static void Step()