From 8167ab990bffea6c96d9215cd1f76e8600bd1e7a Mon Sep 17 00:00:00 2001 From: spatialfree Date: Fri, 8 Nov 2024 23:20:38 -0500 Subject: [PATCH] headmove tail move deltabools --- src/Arts.cs | 17 ++++++++++++++++- src/Program.cs | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Arts.cs b/src/Arts.cs index bc06113..30f6eb6 100644 --- a/src/Arts.cs +++ b/src/Arts.cs @@ -13,6 +13,11 @@ static class Arts static Quat food_ori = Quat.Identity; + static XYZi last_headpos = new(0, 0, 0); + static DeltaBool headmove = new(false); + static XYZi last_tailpos = new(0, 0, 0); + static DeltaBool tailmove = new(false); + public static void Init() { foreach (ModelNode node in assets_model.Nodes) @@ -76,7 +81,7 @@ static class Arts } // snake - float snake_t = Maths.smooth_stop((float)Mono.step_t); + float snake_t = headmove.state ? Maths.u_clamp(Maths.smooth_stop((float)Mono.step_t) * 3.0f) : 1.0f; bool food_next = (Mono.snake[0] + Mono.snake_dir) == Mono.food; if (!food_next) { @@ -181,4 +186,14 @@ static class Arts // } // } } + + public static void Step() + { + XYZi snake_head = Mono.snake[0]; + XYZi snake_tail = Mono.snake[Mono.snake_len -1]; + headmove.Step(snake_head != last_headpos); + tailmove.Step(snake_tail != last_tailpos); + last_headpos = snake_head; + last_tailpos = snake_tail; + } } \ No newline at end of file diff --git a/src/Program.cs b/src/Program.cs index 1319b2c..a6a1f41 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -52,6 +52,7 @@ class Program Mono.step_time -= Mono.step_step; Mono.Step(); + Arts.Step(); } Arts.Frame();