eaten latch

This commit is contained in:
ethan merchant 2024-11-10 03:54:50 -05:00
parent f696952488
commit 40d3780319

View file

@ -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 (food == snake[0]) if (!eaten_latch)
{ {
eat_timestamp = Time.Total; if (food == snake[0])
grow_buffer += 3; {
eaten_latch = true;
eat_timestamp = Time.Total;
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;
}
} }
} }