Compare commits
12 commits
e9a317bfec
...
a59110067e
Author | SHA1 | Date | |
---|---|---|---|
a59110067e | |||
59c0d5ee4d | |||
9914948a50 | |||
90c3d806c6 | |||
284f6e9b23 | |||
5855e4a5d0 | |||
335cf3b8ac | |||
d46d4b0af1 | |||
28195a9549 | |||
7ce5690db4 | |||
5579f6b39b | |||
d8c74d29d1 |
6 changed files with 52 additions and 57 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,5 +8,5 @@ obj/
|
|||
|
||||
Raw/
|
||||
|
||||
|
||||
.vscode
|
||||
anchors.txt
|
|
@ -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" />
|
||||
|
|
|
@ -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"
|
||||
```
|
||||
|
|
38
src/Arts.cs
38
src/Arts.cs
|
@ -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
|
||||
)
|
||||
);
|
||||
|
|
61
src/Mono.cs
61
src/Mono.cs
|
@ -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)
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class Program
|
|||
return;
|
||||
|
||||
Renderer.Scaling = 2;
|
||||
// World.OcclusionEnabled = true;
|
||||
World.OcclusionEnabled = true;
|
||||
// Device.DisplayBlend = DisplayBlend.Blend;
|
||||
|
||||
Rig.Init();
|
||||
|
|
Loading…
Add table
Reference in a new issue