don't fall
This commit is contained in:
parent
d46d4b0af1
commit
335cf3b8ac
2 changed files with 2 additions and 46 deletions
17
src/Arts.cs
17
src/Arts.cs
|
@ -76,20 +76,13 @@ static class Arts
|
||||||
}
|
}
|
||||||
|
|
||||||
// snake
|
// snake
|
||||||
float fall_t = 0.0f;
|
|
||||||
if (Mono.snake_fall.state)
|
|
||||||
{
|
|
||||||
// if (Mono.snake_fall.delta == +1) // start falling
|
|
||||||
fall_t = 1.0f - (float)Mono.step_t;
|
|
||||||
}
|
|
||||||
Vec3 fall = V.XYZ(0, fall_t, 0);
|
|
||||||
bool food_next = (Mono.snake[0] + Mono.snake_dir) == Mono.food;
|
bool food_next = (Mono.snake[0] + Mono.snake_dir) == Mono.food;
|
||||||
if (!food_next)
|
if (!food_next)
|
||||||
{
|
{
|
||||||
meshes["Tongue"].Draw(
|
meshes["Tongue"].Draw(
|
||||||
mat_mono,
|
mat_mono,
|
||||||
Matrix.TRS(
|
Matrix.TRS(
|
||||||
Mono.snake[0].ToVec3 + fall,
|
Mono.snake[0].ToVec3,
|
||||||
Quat.LookDir(Rig.fullstick),
|
Quat.LookDir(Rig.fullstick),
|
||||||
V.XYZ(1, 1, 0.666f + Maths.smooth_stop((float)Mono.step_t) * 0.333f)
|
V.XYZ(1, 1, 0.666f + Maths.smooth_stop((float)Mono.step_t) * 0.333f)
|
||||||
)
|
)
|
||||||
|
@ -138,12 +131,6 @@ static class Arts
|
||||||
|
|
||||||
|
|
||||||
// food
|
// food
|
||||||
float food_fall_t = 0.0f;
|
|
||||||
if (Mono.food_fall.state)
|
|
||||||
{
|
|
||||||
// if (Mono.food_fall.delta == +1) // start falling
|
|
||||||
food_fall_t = 1.0f - (float)Mono.step_t;
|
|
||||||
}
|
|
||||||
if (!food_next)
|
if (!food_next)
|
||||||
{
|
{
|
||||||
food_ori *= Quat.FromAngles(
|
food_ori *= Quat.FromAngles(
|
||||||
|
@ -155,7 +142,7 @@ static class Arts
|
||||||
meshes["Food"].Draw(
|
meshes["Food"].Draw(
|
||||||
mat_mono,
|
mat_mono,
|
||||||
Matrix.TR(
|
Matrix.TR(
|
||||||
Mono.food.ToVec3 + V.XYZ(0, food_fall_t, 0),
|
Mono.food.ToVec3,
|
||||||
food_ori
|
food_ori
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
31
src/Mono.cs
31
src/Mono.cs
|
@ -26,10 +26,8 @@ static class Mono
|
||||||
public static int grow_buffer = 0;
|
public static int grow_buffer = 0;
|
||||||
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 DeltaBool snake_fall = new(false);
|
|
||||||
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);
|
||||||
public static DeltaBool food_fall = new(false);
|
|
||||||
public static double eat_timestamp = 0.0;
|
public static double eat_timestamp = 0.0;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
|
@ -116,35 +114,6 @@ static class Mono
|
||||||
snake[0] += snake_dir;
|
snake[0] += snake_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
// gravity
|
|
||||||
bool grounded = false;
|
|
||||||
for (int i = 0; i < snake_len; i++)
|
|
||||||
{
|
|
||||||
if (snake[i].y == -SD_Y)
|
|
||||||
{
|
|
||||||
grounded = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
snake_fall.Step(!grounded && holes.Count == 0);
|
|
||||||
if (snake_fall.state)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < snake_len; i++)
|
|
||||||
{
|
|
||||||
snake[i] -= new XYZi(0, 1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool food_grounded = food.y == -SD_Y;
|
|
||||||
XYZi below_food = new XYZi(food.x, food.y - 1, food.z);
|
|
||||||
bool on_snake = s_array.InRange(below_food) && s_array[below_food] > -1;
|
|
||||||
food_fall.Step(!food_grounded && !on_snake);
|
|
||||||
if (food_fall.state)
|
|
||||||
{
|
|
||||||
food -= new XYZi(0, 1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
in_box.Step(s_array.InRange(snake[0]));
|
in_box.Step(s_array.InRange(snake[0]));
|
||||||
if (in_box.delta != 0) // 1 just in -1 just out
|
if (in_box.delta != 0) // 1 just in -1 just out
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue