eaten latch delta bool
This commit is contained in:
parent
9b5a17cb0c
commit
2900070ea9
2 changed files with 8 additions and 8 deletions
|
@ -93,7 +93,7 @@ static class Arts
|
||||||
|
|
||||||
// snake
|
// snake
|
||||||
float snake_t = headmove.state ? Maths.u_clamp(Maths.smooth_stop((float)Mono.step_t) * 3.0f) : 1.0f;
|
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)
|
if (!food_next)
|
||||||
{
|
{
|
||||||
meshes["Tongue"].Draw(
|
meshes["Tongue"].Draw(
|
||||||
|
@ -169,7 +169,7 @@ static class Arts
|
||||||
10 * Time.Stepf
|
10 * Time.Stepf
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!Mono.eaten_latch)
|
if (!Mono.eaten_latch.state)
|
||||||
{
|
{
|
||||||
meshes["Food"].Draw(
|
meshes["Food"].Draw(
|
||||||
mat_mono,
|
mat_mono,
|
||||||
|
|
12
src/Mono.cs
12
src/Mono.cs
|
@ -27,7 +27,7 @@ static class Mono
|
||||||
public static DeltaBool in_box = new(true);
|
public static DeltaBool in_box = new(true);
|
||||||
public static Dictionary<XYZi, XYZi> holes = new();
|
public static Dictionary<XYZi, XYZi> holes = new();
|
||||||
public static XYZi food = new(2, 0, 0); // [!] start random to keep new game fresh?
|
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 static double eat_timestamp = 0.0;
|
||||||
|
|
||||||
public enum BoxMode
|
public enum BoxMode
|
||||||
|
@ -181,11 +181,11 @@ static class Mono
|
||||||
}
|
}
|
||||||
|
|
||||||
// eat
|
// 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;
|
eat_timestamp = Time.Total;
|
||||||
grow_buffer += 3;
|
grow_buffer += 3;
|
||||||
|
|
||||||
|
@ -193,10 +193,10 @@ static class Mono
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
(bool viable, XYZi cell) = Feed();
|
(bool viable, XYZi cell) = Feed();
|
||||||
if (viable)
|
eaten_latch.Step(!viable);
|
||||||
|
if (eaten_latch.delta == -1)
|
||||||
{
|
{
|
||||||
food = cell;
|
food = cell;
|
||||||
eaten_latch = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue