diff --git a/src/Arts.cs b/src/Arts.cs index 8750544..3d56c4c 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -93,7 +93,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 && (Mono.snake[0] + Mono.snake_dir) == Mono.food; + bool food_next = !Mono.eaten_latch.state && (Mono.snake[0] + Mono.snake_dir) == Mono.food; if (!food_next) { meshes["Tongue"].Draw( @@ -169,7 +169,7 @@ static class Arts 10 * Time.Stepf ); } - if (!Mono.eaten_latch) + if (!Mono.eaten_latch.state) { meshes["Food"].Draw( mat_mono, diff --git a/src/Mono.cs b/src/Mono.cs index 0d3182a..9828181 100644 --- a/src/Mono.cs +++ b/src/Mono.cs @@ -27,7 +27,7 @@ static class Mono public static DeltaBool in_box = new(true); public static Dictionary holes = new(); public static XYZi food = new(2, 0, 0); // [!] start random to keep new game fresh? - public static bool eaten_latch = false; + public static DeltaBool eaten_latch = new(false); public static double eat_timestamp = 0.0; public enum BoxMode @@ -181,11 +181,11 @@ static class Mono } // eat - if (!eaten_latch) + if (!eaten_latch.state) { - if (food == snake[0]) + eaten_latch.Step(food == snake[0]); + if (eaten_latch.delta == +1) { - eaten_latch = true; eat_timestamp = Time.Total; grow_buffer += 3; @@ -193,10 +193,10 @@ static class Mono } } else { (bool viable, XYZi cell) = Feed(); - if (viable) + eaten_latch.Step(!viable); + if (eaten_latch.delta == -1) { food = cell; - eaten_latch = false; } } }