Compare commits
19 commits
8f5ad356fe
...
f38a9b19d7
Author | SHA1 | Date | |
---|---|---|---|
f38a9b19d7 | |||
b8777ca9c2 | |||
c5e25f37b0 | |||
9574f17a8d | |||
c906fb2884 | |||
1a91c9bc56 | |||
49c789b1f5 | |||
a9ed3aec75 | |||
a335a7ad25 | |||
4e41ec5ed1 | |||
cf0c656f72 | |||
e1d72e8f3d | |||
7de0458ef4 | |||
32bb4364d6 | |||
00c230b6d7 | |||
19b75c3cce | |||
480506b715 | |||
deece71de8 | |||
76d72afef9 |
10 changed files with 136 additions and 34 deletions
|
@ -8,10 +8,12 @@ float4 color;
|
|||
struct vsIn {
|
||||
float4 pos : SV_Position;
|
||||
float3 norm : NORMAL0;
|
||||
float2 uv : TEXCOORD0;
|
||||
// float4 col : COLOR0;
|
||||
};
|
||||
struct psIn {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 color : COLOR0;
|
||||
float3 normal : NORMAL0;
|
||||
float3 world_pos : WORLD;
|
||||
|
@ -35,6 +37,7 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
// flip input normals to treat backfaces like normal
|
||||
o.normal = normalize(mul(-input.norm, (float3x3)sk_inst[id].world));
|
||||
|
||||
o.uv = input.uv;
|
||||
o.color = color * sk_inst[id].color;
|
||||
|
||||
return o;
|
||||
|
|
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
BIN
Assets/meshes/assets.glb
(Stored with Git LFS)
Binary file not shown.
|
@ -2,13 +2,8 @@
|
|||
|
||||
//--name = dofdev/mono
|
||||
//--color:color = 1, 1, 1, 1
|
||||
//--tex_scale = 1
|
||||
//--diffuse = white
|
||||
|
||||
float4 color;
|
||||
float tex_scale;
|
||||
Texture2D diffuse : register(t0);
|
||||
SamplerState diffuse_s : register(s0);
|
||||
|
||||
struct vsIn {
|
||||
float4 pos : SV_Position;
|
||||
|
@ -33,16 +28,12 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
|
||||
float3 normal = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||
|
||||
o.uv = input.uv * tex_scale;
|
||||
o.uv = input.uv;
|
||||
float3 norm_color = float3(0.5) + (normal * 0.5);
|
||||
float3 norm_shade = float3(0.5) + (norm_color * 0.5);
|
||||
o.color = float4(norm_shade, 1) * input.col; // input.col * color * sk_inst[id].color;
|
||||
return o;
|
||||
}
|
||||
float4 ps(psIn input) : SV_TARGET {
|
||||
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
||||
|
||||
col = col * input.color;
|
||||
|
||||
return col;
|
||||
return input.color;
|
||||
}
|
BIN
Assets/paper.jpg
Normal file
BIN
Assets/paper.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 382 KiB |
|
@ -2,13 +2,8 @@
|
|||
|
||||
//--name = dofdev/unlit
|
||||
//--color:color = 1, 1, 1, 1
|
||||
//--tex_scale = 1
|
||||
//--diffuse = white
|
||||
|
||||
float4 color;
|
||||
float tex_scale;
|
||||
Texture2D diffuse : register(t0);
|
||||
SamplerState diffuse_s : register(s0);
|
||||
|
||||
struct vsIn {
|
||||
float4 pos : SV_Position;
|
||||
|
@ -33,14 +28,10 @@ psIn vs(vsIn input, uint id : SV_InstanceID) {
|
|||
|
||||
float3 normal = normalize(mul(input.norm, (float3x3)sk_inst[id].world));
|
||||
|
||||
o.uv = input.uv * tex_scale;
|
||||
o.uv = input.uv;
|
||||
o.color = input.col * color * sk_inst[id].color;
|
||||
return o;
|
||||
}
|
||||
float4 ps(psIn input) : SV_TARGET {
|
||||
float4 col = diffuse.Sample(diffuse_s, input.uv);
|
||||
|
||||
col = col * input.color;
|
||||
|
||||
return col;
|
||||
return input.color;
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.dofdev.snake"
|
||||
android:versionCode="29"
|
||||
android:versionName="1.32"
|
||||
android:versionCode="34"
|
||||
android:versionName="1.38"
|
||||
android:installLocation="auto"
|
||||
>
|
||||
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="32" />
|
||||
|
|
53
src/Arts.cs
53
src/Arts.cs
|
@ -1,5 +1,4 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using StereoKit;
|
||||
|
||||
namespace snake;
|
||||
|
@ -14,6 +13,7 @@ static class Arts
|
|||
static Material mat_backbox = new Material("backbox.hlsl");
|
||||
static Material mat_justcolor = new Material("justcolor.hlsl");
|
||||
|
||||
public static Vec3 box_shake = new(0, 0, 0);
|
||||
static Quat food_ori = Quat.Identity;
|
||||
|
||||
static XYZi last_headpos = new(0, 0, 0);
|
||||
|
@ -21,6 +21,8 @@ static class Arts
|
|||
static XYZi last_tailpos = new(0, 0, 0);
|
||||
static DeltaBool tailmove = new(false);
|
||||
|
||||
static TextStyle text_style;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
foreach (ModelNode node in assets_model.Nodes)
|
||||
|
@ -31,6 +33,11 @@ static class Arts
|
|||
}
|
||||
}
|
||||
|
||||
text_style = TextStyle.FromFont(
|
||||
Font.FromFile("HurmitNerd.otf"),
|
||||
1.0f * U.cm,
|
||||
Color.White
|
||||
);
|
||||
|
||||
mat_backbox.FaceCull = Cull.Front;
|
||||
mat_backbox.Transparency = Transparency.Add;
|
||||
|
@ -44,7 +51,7 @@ static class Arts
|
|||
{
|
||||
bool vr = Device.DisplayBlend == DisplayBlend.Opaque;
|
||||
// render hands if not in mixed reality
|
||||
// Input.HandVisible(Handed.Max, vr);
|
||||
Input.HandVisible(Handed.Max, false);
|
||||
if (vr)
|
||||
{
|
||||
// background standin if no passthrough
|
||||
|
@ -67,9 +74,14 @@ static class Arts
|
|||
);
|
||||
|
||||
// box
|
||||
box_shake = Vec3.Lerp(box_shake, Vec3.Zero, Time.Stepf / 0.333f);
|
||||
// scale in
|
||||
float box_scale = Mono.box_scale; // Maths.min(Maths.smooth_stop(Maths.u_scalar(Time.Totalf - 3)) * Mono.box_scale, Mono.box_scale);
|
||||
Hierarchy.Push(Mono.box_pose.ToMatrix(box_scale));
|
||||
Hierarchy.Push(Matrix.TRS(
|
||||
Mono.box_pose.position + (box_shake * U.cm * 0.333f),
|
||||
Mono.box_pose.orientation,
|
||||
box_scale
|
||||
));
|
||||
// meshes["InsideOut"].Draw(mat_unlit, Matrix.Identity);
|
||||
meshes["InsideOut"].Draw(
|
||||
mat_box,
|
||||
|
@ -81,9 +93,11 @@ static class Arts
|
|||
);
|
||||
if (Mono.in_cone.state && Mono.box_mode == Mono.BoxMode.Hold || Mono.box_mode == Mono.BoxMode.Mount)
|
||||
{
|
||||
meshes["Hanging"].Draw(
|
||||
mat_unlit,
|
||||
Matrix.Identity
|
||||
Lines.Add(
|
||||
V.XYZ(0, Mono.SD_Y - 0.5f, 0),
|
||||
V.XYZ(0, Mono.SD_Y + 3.0f, 0),
|
||||
Color.White,
|
||||
1.0f * U.mm
|
||||
);
|
||||
}
|
||||
if (Mono.menu)
|
||||
|
@ -215,6 +229,33 @@ static class Arts
|
|||
);
|
||||
}
|
||||
|
||||
// particles
|
||||
Particle[] particles = VFX.particles;
|
||||
for (int i = 0; i < particles.Length; i++)
|
||||
{
|
||||
Particle particle = particles[i];
|
||||
meshes["FoodParticle"].Draw(
|
||||
mat_mono,
|
||||
Matrix.TRS(
|
||||
particle.pos,
|
||||
particle.ori,
|
||||
particle.scl
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// score
|
||||
Quat score_ori = Quat.LookDir(Rig.head.position - Mono.box_pose.position);
|
||||
Text.Add(
|
||||
Mono.snake_len.ToString("000"),
|
||||
Matrix.TRS(
|
||||
score_ori * V.XYZ(0, -Mono.SD_Y - 1, -Mono.SD_Z - 1),
|
||||
score_ori,
|
||||
32
|
||||
),
|
||||
text_style
|
||||
);
|
||||
|
||||
Hierarchy.Pop();
|
||||
|
||||
// for (int sx = -Mono.head_fill.Xslen; Mono.head_fill.InX(sx); sx++)
|
||||
|
|
|
@ -30,7 +30,7 @@ static class Mono
|
|||
public static XYZi snake_dir = new(0, 0, 1);
|
||||
public static DeltaBool in_box = new(true);
|
||||
public static Dictionary<XYZi, XYZi> holes = new();
|
||||
public static XYZi food = new(2, 0, 0); // [!] start random to keep new game fresh?
|
||||
public static XYZi food = new(0, -1, 0); // [!] start random to keep new game fresh?
|
||||
public static DeltaBool eaten_latch = new(false);
|
||||
public static double eat_timestamp = 0.0;
|
||||
|
||||
|
@ -66,7 +66,9 @@ static class Mono
|
|||
// just one btn(resume) in menu rn
|
||||
if (Rig.btn_select.delta == +1)
|
||||
{
|
||||
Rig.btn_select.delta = 0; // [!] hacky capture
|
||||
menu = false;
|
||||
SFX.click.PlayBox(new XYZi(0, 0, Mono.SD_Z + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,6 +177,7 @@ static class Mono
|
|||
{
|
||||
holes.Add(snake[0], snake_dir);
|
||||
SFX.punch_through.PlayBox(snake[0]);
|
||||
Arts.box_shake += snake_dir.ToVec3;
|
||||
}
|
||||
if (holes.ContainsKey(snake[snake_len - 1]))
|
||||
{
|
||||
|
@ -196,6 +199,7 @@ static class Mono
|
|||
eat_timestamp = Time.Total;
|
||||
grow_buffer += 3;
|
||||
|
||||
VFX.Play(snake[0]);
|
||||
SFX.crisp_nom.PlayBox(snake[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class Program
|
|||
|
||||
Rig.Init();
|
||||
Mono.Init();
|
||||
VFX.Init();
|
||||
Arts.Init();
|
||||
|
||||
VCam.Init();
|
||||
|
@ -97,6 +98,8 @@ class Program
|
|||
Arts.Step();
|
||||
}
|
||||
}
|
||||
|
||||
VFX.Frame();
|
||||
}
|
||||
|
||||
Arts.Frame();
|
||||
|
|
69
src/VFX.cs
Normal file
69
src/VFX.cs
Normal file
|
@ -0,0 +1,69 @@
|
|||
using StereoKit;
|
||||
using System;
|
||||
|
||||
namespace snake;
|
||||
|
||||
static class VFX
|
||||
{
|
||||
public static Particle[] particles = new Particle[32];
|
||||
static int index = 0;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
for (int i = 0; i < particles.Length; i++)
|
||||
{
|
||||
particles[i] = new();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Play(XYZi pos)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
index = (index + 1) % particles.Length;
|
||||
Particle particle = particles[index];
|
||||
particle.pos = pos.ToVec3;
|
||||
particle.vel = Quat.FromAngles(Random.Shared.NextSingle() * 360, 0, 0) * Quat.FromAngles(0, Random.Shared.NextSingle() * 360, 0) * Vec3.Forward * 6.0f;
|
||||
particle.ori = Quat.Identity;
|
||||
particle.scl = (1.0f / 8) * Maths.smooth_stop(Random.Shared.NextSingle());
|
||||
}
|
||||
}
|
||||
|
||||
public static void Frame()
|
||||
{
|
||||
for (int i = 0; i < particles.Length; i++)
|
||||
{
|
||||
Particle particle = particles[i];
|
||||
if (particle.vel.MagnitudeSq > float.Epsilon)
|
||||
{
|
||||
particle.pos += particle.vel * Time.Stepf;
|
||||
float scl_rad = particle.scl * 0.5f * 0.333f;
|
||||
Vec3 next_pos = V.XYZ(
|
||||
Maths.s_clamp(particle.pos.x, Mono.SD_X - 0.5f - scl_rad),
|
||||
Maths.s_clamp(particle.pos.y, Mono.SD_Y - 0.5f - scl_rad),
|
||||
Maths.s_clamp(particle.pos.z, Mono.SD_Z - 0.5f - scl_rad)
|
||||
);
|
||||
if (next_pos.x != particle.pos.x || next_pos.y != particle.pos.y || next_pos.z != particle.pos.z)
|
||||
{
|
||||
particle.pos = next_pos;
|
||||
particle.vel = Vec3.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Particle
|
||||
{
|
||||
public Vec3 pos, vel;
|
||||
public Quat ori;
|
||||
public float scl;
|
||||
|
||||
public Particle()
|
||||
{
|
||||
this.pos = Vec3.Zero;
|
||||
this.vel = Vec3.Zero;
|
||||
this.ori = Quat.Identity;
|
||||
this.scl = 0.0f;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue