eaten latch
This commit is contained in:
parent
f696952488
commit
40d3780319
1 changed files with 20 additions and 6 deletions
18
src/Mono.cs
18
src/Mono.cs
|
@ -26,7 +26,8 @@ static class Mono
|
||||||
public static XYZi snake_dir = new(0, 0, 1);
|
public static XYZi snake_dir = new(0, 0, 1);
|
||||||
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);
|
public static XYZi food = new(2, 0, 0); // [!] start random to keep new game fresh?
|
||||||
|
public static bool eaten_latch = false;
|
||||||
public static double eat_timestamp = 0.0;
|
public static double eat_timestamp = 0.0;
|
||||||
|
|
||||||
public enum BoxMode
|
public enum BoxMode
|
||||||
|
@ -180,13 +181,26 @@ static class Mono
|
||||||
}
|
}
|
||||||
|
|
||||||
// eat
|
// eat
|
||||||
|
if (!eaten_latch)
|
||||||
|
{
|
||||||
if (food == snake[0])
|
if (food == snake[0])
|
||||||
{
|
{
|
||||||
|
eaten_latch = true;
|
||||||
eat_timestamp = Time.Total;
|
eat_timestamp = Time.Total;
|
||||||
grow_buffer += 3;
|
grow_buffer += 3;
|
||||||
|
|
||||||
Feed();
|
|
||||||
SFX.crisp_nom.PlayBox(snake[0]);
|
SFX.crisp_nom.PlayBox(snake[0]);
|
||||||
|
|
||||||
|
// move food out of play
|
||||||
|
food.y = 5;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(bool viable, XYZi cell) = Feed();
|
||||||
|
if (viable)
|
||||||
|
{
|
||||||
|
food = cell;
|
||||||
|
eaten_latch = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue