formatting fixes
This commit is contained in:
parent
35e3a813f2
commit
1cc71b113b
2 changed files with 24 additions and 23 deletions
|
@ -145,7 +145,8 @@ static class Arts
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// false tail
|
// false tail
|
||||||
if (tailmove.state && snake_t < 1.0f) {
|
if (tailmove.state && snake_t < 1.0f)
|
||||||
|
{
|
||||||
int i_tail = Maths.min(Mono.snake_len, Mono.snake.Length - 1);
|
int i_tail = Maths.min(Mono.snake_len, Mono.snake.Length - 1);
|
||||||
Vec3 tail_dir = Vec3.Direction(Mono.snake[i_tail - 1].ToVec3, Mono.snake[i_tail].ToVec3);
|
Vec3 tail_dir = Vec3.Direction(Mono.snake[i_tail - 1].ToVec3, Mono.snake[i_tail].ToVec3);
|
||||||
meshes["Segment"].Draw(
|
meshes["Segment"].Draw(
|
||||||
|
@ -235,7 +236,7 @@ static class Arts
|
||||||
public static void Step()
|
public static void Step()
|
||||||
{
|
{
|
||||||
XYZi snake_head = Mono.snake[0];
|
XYZi snake_head = Mono.snake[0];
|
||||||
XYZi snake_tail = Mono.snake[Mono.snake_len -1];
|
XYZi snake_tail = Mono.snake[Mono.snake_len - 1];
|
||||||
headmove.Step(snake_head != last_headpos);
|
headmove.Step(snake_head != last_headpos);
|
||||||
tailmove.Step(snake_tail != last_tailpos);
|
tailmove.Step(snake_tail != last_tailpos);
|
||||||
last_headpos = snake_head;
|
last_headpos = snake_head;
|
||||||
|
|
42
src/Mono.cs
42
src/Mono.cs
|
@ -16,7 +16,7 @@ static class Mono
|
||||||
public static float box_scale = 1.333f * U.cm;
|
public static float box_scale = 1.333f * U.cm;
|
||||||
public const int SD_X = 3, SD_Y = 2, SD_Z = 3;
|
public const int SD_X = 3, SD_Y = 2, SD_Z = 3;
|
||||||
public static SpatialArray<int>
|
public static SpatialArray<int>
|
||||||
box_space = new(SD_X-1, SD_Y-1, SD_Z-1, -1),
|
box_space = new(SD_X - 1, SD_Y - 1, SD_Z - 1, -1),
|
||||||
s_array = new(SD_X, SD_Y, SD_Z, -1),
|
s_array = new(SD_X, SD_Y, SD_Z, -1),
|
||||||
tail_fill = new(SD_X, SD_Y, SD_Z, -1);
|
tail_fill = new(SD_X, SD_Y, SD_Z, -1);
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ static class Mono
|
||||||
public static void Step()
|
public static void Step()
|
||||||
{
|
{
|
||||||
// eat tail
|
// eat tail
|
||||||
if (snake[0] + snake_dir == snake[snake_len-1])
|
if (snake[0] + snake_dir == snake[snake_len - 1])
|
||||||
{
|
{
|
||||||
snake_len--;
|
snake_len--;
|
||||||
grow_buffer = 0;
|
grow_buffer = 0;
|
||||||
|
@ -190,7 +190,9 @@ static class Mono
|
||||||
|
|
||||||
SFX.crisp_nom.PlayBox(snake[0]);
|
SFX.crisp_nom.PlayBox(snake[0]);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
(bool viable, XYZi cell) = Feed();
|
(bool viable, XYZi cell) = Feed();
|
||||||
eaten_latch.Step(!viable);
|
eaten_latch.Step(!viable);
|
||||||
if (eaten_latch.delta == -1)
|
if (eaten_latch.delta == -1)
|
||||||
|
@ -250,7 +252,7 @@ static class Mono
|
||||||
XYZi _sv = queue.Dequeue();
|
XYZi _sv = queue.Dequeue();
|
||||||
int currentDistance = fill_array[_sv];
|
int currentDistance = fill_array[_sv];
|
||||||
|
|
||||||
// check all 4 directions
|
// check all 6 directions
|
||||||
foreach (XYZi dir in directions)
|
foreach (XYZi dir in directions)
|
||||||
{
|
{
|
||||||
XYZi newV = _sv + dir;
|
XYZi newV = _sv + dir;
|
||||||
|
@ -274,9 +276,7 @@ static class Mono
|
||||||
for (int i = indices.Length - 1; i > 0; i--)
|
for (int i = indices.Length - 1; i > 0; i--)
|
||||||
{
|
{
|
||||||
int j = System.Random.Shared.Next(i + 1);
|
int j = System.Random.Shared.Next(i + 1);
|
||||||
int temp = indices[i];
|
(indices[j], indices[i]) = (indices[i], indices[j]);
|
||||||
indices[i] = indices[j];
|
|
||||||
indices[j] = temp;
|
|
||||||
}
|
}
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
@ -284,23 +284,23 @@ static class Mono
|
||||||
// directions for moving in the grid
|
// directions for moving in the grid
|
||||||
static readonly XYZi[] directions = new XYZi[]
|
static readonly XYZi[] directions = new XYZi[]
|
||||||
{
|
{
|
||||||
new XYZi(-1, 0, 0), // lft
|
new(-1, 0, 0), // lft
|
||||||
new XYZi(+1, 0, 0), // rht
|
new(+1, 0, 0), // rht
|
||||||
new XYZi(0, -1, 0), // dwn
|
new(0, -1, 0), // dwn
|
||||||
new XYZi(0, +1, 0), // up
|
new(0, +1, 0), // up
|
||||||
new XYZi(0, 0, -1), // fwd
|
new(0, 0, -1), // fwd
|
||||||
new XYZi(0, 0, +1), // back
|
new(0, 0, +1), // back
|
||||||
};
|
};
|
||||||
static readonly XYZi[] corners = new XYZi[]
|
static readonly XYZi[] corners = new XYZi[]
|
||||||
{
|
{
|
||||||
new XYZi(-1, -1, -1),
|
new(-1, -1, -1),
|
||||||
new XYZi(-1, -1, +1),
|
new(-1, -1, +1),
|
||||||
new XYZi(-1, +1, -1),
|
new(-1, +1, -1),
|
||||||
new XYZi(-1, +1, +1),
|
new(-1, +1, +1),
|
||||||
new XYZi(+1, -1, -1),
|
new(+1, -1, -1),
|
||||||
new XYZi(+1, -1, +1),
|
new(+1, -1, +1),
|
||||||
new XYZi(+1, +1, -1),
|
new(+1, +1, -1),
|
||||||
new XYZi(+1, +1, +1)
|
new(+1, +1, +1)
|
||||||
};
|
};
|
||||||
|
|
||||||
static XYZi InsetCell(XYZi cell)
|
static XYZi InsetCell(XYZi cell)
|
||||||
|
|
Loading…
Add table
Reference in a new issue