eaten latch delta bool

This commit is contained in:
ethan merchant 2024-11-10 04:20:58 -05:00
parent 9b5a17cb0c
commit 2900070ea9
2 changed files with 8 additions and 8 deletions

View file

@ -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,

View file

@ -27,7 +27,7 @@ static class Mono
public static DeltaBool in_box = new(true);
public static Dictionary<XYZi, XYZi> 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;
}
}
}