Game class cleaned up

This commit is contained in:
spatialfree 2022-08-02 22:04:28 -04:00
parent 4469ddf400
commit a829a63c94
2 changed files with 39 additions and 71 deletions

View file

@ -1,3 +1,4 @@
namespace Oriels;
public static class PullRequest {
public static void BoundsDraw(Bounds b, float thickness, Color color) {
Vec3 c = Vec3.One / 2;

View file

@ -1,5 +1,12 @@
using System.Collections.Generic;
// stretch cursor move
// trackballer spin
// orbital view
// dummy enemies
// points (point of reference *all around)
// roll dodge move
namespace Space;
public class Mono {
@ -18,49 +25,15 @@ public class Mono {
}
public void Frame() {
Rig rig = Oriels.Mono.inst.rig;
Oriel oriel = Oriels.Mono.inst.oriel;
// stretch cursor move
// trackballer spin
// orbital view
// dummy enemies
// points (point of reference *all around)
// roll dodge move
// placeholder "app"
// Vec3 playerWorldPos = playerPos * 0.5f * oriel.bounds.dimensions.y;
Matrix orielSimMatrix = Matrix.TRS(
new Vec3(0, 0, 0), //-oriel.bounds.dimensions.y / 2.01f, -playerWorldPos.z),
Quat.Identity,
Vec3.One * 0.5f * oriel.bounds.dimensions.y
);
// meshCube.Draw(oriel.matOriel,
// rGlove.virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3 * 1.05f),
// new Color(0.3f, 0.3f, 0.6f)
// );
// go hacky for now, just to show that you are doing something
// but communicate that:
// there are a whole host of things that are taken for granted rn
// that need to be implemented for the real thing
// they aren't that hard, i just can't panic rush through them
// because they are mundane and somewhat time consuming
// we can show dedication and communicate/ensure importance by streaming and making videos again!
// stretch cursor pattern:
// stretch = dist(offHand, mainHand)
// max(stretch - deadzone, 0)
@ -71,24 +44,30 @@ public class Mono {
float deadzone = 0.1f;
float stretch = Vec3.Distance(rig.lCon.pos, rig.rCon.pos);
stretch = Math.Max(stretch - deadzone, 0);
Vec3 cursor = rig.rCon.pos + rig.rCon.ori * Vec3.Forward * stretch * 3;
Vec3 localCursor = orielSimMatrix.Inverse.Transform(oriel.matrix.Transform(cursor));
// fly player towards cursor:
// playerPos += (localCursor - playerPos).Normalized * 1f * Time.Elapsedf;
playerPos = new Vec3(
pidX.Update(localCursor.x),
pidY.Update(localCursor.y),
pidZ.Update(localCursor.z)
);
// RENDER
meshCube.Draw(oriel.matOriel,
Matrix.TRS(cursor, Quat.Identity, Vec3.One * 0.02f),
new Color(1f, 1f, 1f)
);
Vec3 localCursor = orielSimMatrix.Inverse.Transform(oriel.matrix.Transform(cursor));
meshCube.Draw(oriel.matOriel,
Matrix.TRS(localCursor, Quat.Identity, Vec3.One * 0.02f) * orielSimMatrix * oriel.matrix.Inverse,
new Color(0f, 0f, 0f)
);
// fly player towards cursor:
playerPos += (localCursor - playerPos).Normalized * 1f * Time.Elapsedf;
// use the gorilla tag equation to stop the stutter at when the player is close to the cursor
meshCube.Draw(oriel.matOriel,
Matrix.TRS(
playerPos,
@ -98,11 +77,18 @@ public class Mono {
new Color(1.0f, 0.0f, 0.05f)
);
// meshCube.Draw(oriel.matOriel,
// rGlove.virtualGlove.ToMatrix(new Vec3(0.025f, 0.1f, 0.1f) / 3 * 1.05f),
// new Color(0.3f, 0.3f, 0.6f)
// );
return;
// ENEMIES
// destroy enemies that are too close to the playerPos
for (int i = 0; i < enemies.Count; i++) {
if (Vec3.Distance(enemies[i], playerPos) < 0.5f) {
@ -112,20 +98,6 @@ public class Mono {
}
}
// FULLSTICK
// Vec3 Fullstick() {
// Controller con = rig.lCon.device;
// Quat rot = Quat.FromAngles(con.stick.y * -90, 0, con.stick.x * 90);
// Vec3 dir = Vec3.Up * (con.IsStickClicked ? -1 : 1);
// return con.aim.orientation * rot * dir;
// }
// Vec3 fullstick = Fullstick();
// sword.Move(playerPos + simOffset + fullstick, Quat.LookAt(Vec3.Zero, fullstick, Vec3.Up));
// meshCube.Draw(oriel.matOriel,
// Matrix.TRS(sword.GetPose().position + (Vec3.Up * 0.7f) + (sword.GetPose().orientation * Vec3.Forward * -0.5f) - simOffset, sword.GetPose().orientation, new Vec3(0.1f, 0.03f, 1f)) * orielSimMatrix * matrix.Inverse,
// new Color(0.9f, 0.5f, 0.5f)
// );
if (enemies.Count < 100 && Time.Totalf > spawnTime) {
// enemies.Add(playerPos + Quat.FromAngles(0, Oriels.Mono.inst.noise.value * 360f, 0) * Vec3.Forward * 8);
spawnTime = Time.Totalf + 0.05f;
@ -145,21 +117,11 @@ public class Mono {
while (iteration < 6) {
for (int j = 0; j < enemies.Count; j++) {
if (i == j) continue;
// intersection depth
float radius = 0.5f;
// (newPos - enemies[j]).Length
float depth = (newPos - enemies[j]).Length - radius;
if (depth < 0) {
// pull back
Vec3 toEnemy = (enemies[j] - newPos).Normalized;
newPos = enemies[j] - toEnemy * radius * 1.01f;
// bump
// enemies[j] += toEnemy * Time.Elapsedf * 0.5f;
// setNewPos = false;
// break;
// break;
}
}
@ -170,9 +132,6 @@ public class Mono {
enemies[i] = newPos;
}
meshCube.Draw(oriel.matOriel,
Matrix.TRS(enemies[i],
Quat.LookAt(enemies[i], playerPos, Vec3.Up),
@ -181,6 +140,14 @@ public class Mono {
Color.White * 0.62f
);
}
}
// design variables
// move back up and put 2 variables instead down here
// instantiate with default values
// scalar functionality for PID
Oriels.PullRequest.PID pidX = new Oriels.PullRequest.PID(8, 0.3f);
Oriels.PullRequest.PID pidY = new Oriels.PullRequest.PID(8, 0.3f);
Oriels.PullRequest.PID pidZ = new Oriels.PullRequest.PID(8, 0.3f);
}