Compare commits

...

12 commits

Author SHA1 Message Date
a59110067e smooth snake 2024-11-08 22:01:21 -05:00
59c0d5ee4d inset_pos in range refactor 2024-11-08 21:56:48 -05:00
9914948a50 world occlusion enabled 2024-11-08 21:53:24 -05:00
90c3d806c6 ignore vscode 2024-11-08 21:52:56 -05:00
284f6e9b23 around box check 2024-11-08 21:52:45 -05:00
5855e4a5d0 direction corners 2024-11-08 21:52:15 -05:00
335cf3b8ac don't fall 2024-11-08 21:45:08 -05:00
d46d4b0af1 hole grapple check 2024-11-08 21:39:53 -05:00
28195a9549 !neck_break bool 2024-11-08 21:39:10 -05:00
7ce5690db4 lower flatscreen box pose view 2024-11-04 06:41:07 -05:00
5579f6b39b debug cmd 2024-11-04 06:40:31 -05:00
d8c74d29d1 remove store unsupported feature 2024-11-04 06:39:40 -05:00
6 changed files with 52 additions and 57 deletions

2
.gitignore vendored
View file

@ -8,5 +8,5 @@ obj/
Raw/
.vscode
anchors.txt

View file

@ -45,7 +45,6 @@
<uses-permission android:name="com.oculus.permission.EYE_TRACKING" />
<uses-permission android:name="com.oculus.permission.USE_ANCHOR_API" />
<uses-permission android:name="com.oculus.permission.USE_SCENE" />
<uses-feature android:name="com.oculus.experimental.enabled" android:required="true" />
<uses-feature android:name="com.oculus.feature.PASSTHROUGH" android:required="true" />
<uses-feature android:name="oculus.software.handtracking" android:required="false" />
<uses-feature android:name="com.oculus.software.body_tracking" android:required="false" />

View file

@ -26,12 +26,15 @@ adb connect 192.168.1.219
dotnet publish -c Release Projects/Android/snake.Android.csproj
adb install Projects/Android/bin/Release/net7.0-android/com.dofdev.snake-Signed.apk
adb shell monkey -p com.dofdev.snake 1
# upload quest
source .env
./ovr-platform-util upload-quest-build -a $APP_ID -s $APP_SECRET --apk $APK_PATH -c alpha -n "message"
# debug
adb logcat | grep com.dofdev.snake
# install a specific android platform
sdkmanager "platforms;android-33" "build-tools;33.0.0"
```

View file

@ -76,20 +76,14 @@ static class Arts
}
// 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);
float snake_t = Maths.smooth_stop((float)Mono.step_t);
bool food_next = (Mono.snake[0] + Mono.snake_dir) == Mono.food;
if (!food_next)
{
meshes["Tongue"].Draw(
mat_mono,
Matrix.TRS(
Mono.snake[0].ToVec3 + fall,
Mono.snake[0].ToVec3,
Quat.LookDir(Rig.fullstick),
V.XYZ(1, 1, 0.666f + Maths.smooth_stop((float)Mono.step_t) * 0.333f)
)
@ -100,13 +94,13 @@ static class Arts
meshes[face].Draw(
mat_mono,
Matrix.TRS(
Mono.snake[0].ToVec3 + fall,
Mono.snake[0].ToVec3 - (Mono.snake_dir.ToVec3 * (float)(1.0 - snake_t) * 0.3f),
Quat.LookDir(Mono.snake_dir.ToVec3),
V.XYZ(1, 1, 1)// * (float)(Mono.step_t))
V.XYZ(1, 1, (float)(snake_t))
)
);
for (int i = 1; i < Mono.snake_len; i++)
for (int i = 1; i < Mono.snake_len - 1; i++)
{
float scale = 1.0f;
if ((int)((Time.Total - Mono.eat_timestamp) * Mono.snake_len / Mono.step_step) == i)
@ -116,12 +110,24 @@ static class Arts
meshes["Segment"].Draw(
mat_mono,
Matrix.TRS(
Mono.snake[i].ToVec3 + fall,
Mono.snake[i].ToVec3,
Quat.LookAt(Mono.snake[i].ToVec3, Mono.snake[i - 1].ToVec3),
scale
)
);
}
// tail
if (Mono.grow_buffer > 0) { snake_t = 0.0f; }
int i_tail = Mono.snake_len - 1;
Vec3 tail_dir = Vec3.Direction(Mono.snake[i_tail - 1].ToVec3, Mono.snake[i_tail].ToVec3);
meshes["Segment"].Draw(
mat_mono,
Matrix.TRS(
Mono.snake[i_tail].ToVec3 + (tail_dir * (float)(snake_t) * 0.7f),
Quat.LookDir(tail_dir),
V.XYZ(1, 1, (float)(1.0 - snake_t))
)
);
// holes
foreach (KeyValuePair<XYZi, XYZi> hole in Mono.holes)
@ -138,12 +144,6 @@ static class Arts
// 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)
{
food_ori *= Quat.FromAngles(
@ -155,7 +155,7 @@ static class Arts
meshes["Food"].Draw(
mat_mono,
Matrix.TR(
Mono.food.ToVec3 + V.XYZ(0, food_fall_t, 0),
Mono.food.ToVec3,
food_ori
)
);

View file

@ -11,7 +11,7 @@ static class Mono
public static bool menu = true;
public static Pose box_pose = new(0, 0, -10 * U.cm);
public static Pose box_pose = new(0, -3 * U.cm, -10 * U.cm);
public static float box_scale = 1.333f * U.cm;
public const int SD_X = 2, SD_Y = 1, SD_Z = 2;
public static SpatialArray<int>
@ -26,10 +26,8 @@ static class Mono
public static int grow_buffer = 0;
public static XYZi snake_dir = new(0, 0, 1);
public static DeltaBool in_box = new(true);
public static DeltaBool snake_fall = new(false);
public static Dictionary<XYZi, XYZi> holes = new();
public static XYZi food = new(2, 0, 0);
public static DeltaBool food_fall = new(false);
public static double eat_timestamp = 0.0;
public static void Init()
@ -63,8 +61,9 @@ static class Mono
box_pose.position = Rig.head.position + Rig.head.orientation * V.XYZ(0, -(SD_Y + 0.5f) * box_scale, -32 * U.cm);
}
// filter out neck breaking from snake_dir value set
if (snake[0] + Rig.new_dir != snake[1])
XYZi next_pos = snake[0] + Rig.new_dir;
bool neck_break = next_pos == snake[1];
if (!neck_break)
{
snake_dir = Rig.new_dir;
}
@ -90,6 +89,18 @@ static class Mono
return;
}
XYZi next_pos = snake[0] + snake_dir;
XYZi inset_pos = new(
next_pos.x - Maths.sign(next_pos.x),
next_pos.y - Maths.sign(next_pos.y),
next_pos.z - Maths.sign(next_pos.z)
);
bool around_box = s_array.InRange(inset_pos);
if (!around_box)
{
return;
}
if (snake_len == snake.Length)
{
// win condition
@ -115,35 +126,6 @@ static class Mono
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);
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]));
if (in_box.delta != 0) // 1 just in -1 just out
{
@ -245,4 +227,15 @@ static class Mono
new XYZi(0, 0, -1), // fwd
new XYZi(0, 0, +1), // back
};
static readonly XYZi[] corners = new XYZi[]
{
new XYZi(-1, -1, -1),
new XYZi(-1, -1, +1),
new XYZi(-1, +1, -1),
new XYZi(-1, +1, +1),
new XYZi(+1, -1, -1),
new XYZi(+1, -1, +1),
new XYZi(+1, +1, -1),
new XYZi(+1, +1, +1)
};
}

View file

@ -28,7 +28,7 @@ class Program
return;
Renderer.Scaling = 2;
// World.OcclusionEnabled = true;
World.OcclusionEnabled = true;
// Device.DisplayBlend = DisplayBlend.Blend;
Rig.Init();