Restructure some configuration things

This commit is contained in:
msk
2023-09-17 23:51:50 -07:00
parent 5f2a13a7a6
commit 879a2aa2f4
7 changed files with 34 additions and 54 deletions
+12
View File
@@ -1,7 +1,19 @@
namespace WacK.Configuration
{
/// <summary>
/// Player-configured settings that affect gameplay mechanics.
/// Can
/// </summary>
public class PlaySettings
{
/// <summary>
/// Scroll speed multiplier.
/// </summary>
public static float playSpeedMultiplier = 2f;
/// <summary>
/// How much to shift song audio by in seconds.
/// </summary>
public static float audioOffset = 0f;
}
}
+3 -2
View File
@@ -1,8 +1,9 @@
using Godot;
namespace WacK
{
public class Constants
{
public const float SCROLL_MULT = 3f;
public const float NOTE_DRAW_DISTANCE = 10;
public static readonly float BASE_2D_RESOLUTION = 1920f;
}
}
+8 -29
View File
@@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using Godot;
using WacK.Configuration;
using WacK.Data.Chart;
using WacK.Data.Mer;
using WacK.Things.TunnelObjects;
@@ -50,7 +51,13 @@ namespace WacK.Scenes
// base scroll speed, which we can apply multipliers on
public static readonly float BASE_PIXELS_PER_SECOND = 800;
public static float scrollPxPerSec = BASE_PIXELS_PER_SECOND * 3.5f;
public static float scrollPxPerSec
{
get
{
return BASE_PIXELS_PER_SECOND * PlaySettings.playSpeedMultiplier;
}
}
public override void _Ready()
{
@@ -94,34 +101,6 @@ namespace WacK.Scenes
}
}
// private void RealizeHolds(NoteHold note)
// {
// List<Vector2> verts = new(note.points.Count*2 + 2);
// // HoldStart's pos
// verts.Add(new Vector2((float)note.pos * 1920/60, (float)note.time * -scrollPxPerSec));
// // ascending -- "left" side
// foreach (var (t, n) in note.points)
// {
// verts.Add(new Vector2((float)n.pos * 1920/60, t * -scrollPxPerSec));
// }
// // descending -- "right" side
// foreach (var (t, n) in note.points.Reverse())
// {
// verts.Add(new Vector2((float)((int)n.pos + (int)n.size) * 1920/60, t * -scrollPxPerSec));
// }
// // HoldStart's pos + size
// verts.Add(new Vector2((float)((int)note.pos + (int)note.size) * 1920/60, (float)note.time * -scrollPxPerSec));
// var p2d = new Polygon2D
// {
// Polygon = verts.ToArray(),
// Antialiased = true,
// Modulate = new Color("#FFFFFFD0")
// };
// scrollDisplay.AddChild(p2d);
// }
public override void _Process(double delta)
{
var nPos = noteDisplay.Position;
+1 -1
View File
@@ -32,7 +32,7 @@ namespace WacK.Things.TunnelObjects
segmentsNode.AddChild(n);
segments.Add(n);
n.Name = i.ToString();
n.SetPosition(new Vector2(i * 1920 / 60, 0));
n.SetPosition(new Vector2(i * Constants.BASE_2D_RESOLUTION / 60, 0));
}
}
+3 -2
View File
@@ -1,5 +1,7 @@
using System.Linq;
using System.Reflection.Metadata;
using Godot;
using WacK.Configuration;
using WacK.Data.Chart;
using WacK.Scenes;
@@ -47,8 +49,7 @@ namespace WacK.Things.TunnelObjects
private Polygon2D CreateSegment(NotePlay origin, NotePlay destination)
{
Vector2I textureSize = new(1920, 1920);
float minuteSize = textureSize.X / 60;
float minuteSize = Constants.BASE_2D_RESOLUTION / 60;
var length = Play.scrollPxPerSec * (float)(destination.time - origin.time);
var verts = new Vector2[4];
+7 -2
View File
@@ -20,13 +20,18 @@ namespace WacK.Things.TunnelObjects
pos += 1;
size -= 2;
}
else if (size >= 60)
{
size = 60;
// remove padding
}
var nPos = Position;
nPos.X = pos * (1920f/60) - 12;
nPos.X = pos * (Constants.BASE_2D_RESOLUTION/60) - 12;
Position = nPos;
var nSize = Size;
nSize.X = size * (1920f/60) + 24;
nSize.X = size * (Constants.BASE_2D_RESOLUTION/60) + 24;
Size = nSize;
}
}
-18
View File
@@ -10,8 +10,6 @@ using System;
using Godot;
using WacK.Configuration;
namespace WacK
{
public static class Util
@@ -110,22 +108,6 @@ namespace WacK
return 60f / tempo * beatsPerMeasure * ((float)measure + (float)beat / 1920f);
}
public static float NotePosition(int measure, int beat, float tempo, int beatsPerMeasure)
{
if (tempo == 0) return 0; // avoid divide by 0
return TimeToPosition(60f / tempo * beatsPerMeasure * ((float)measure + (float)beat / 1920f));
}
public static float TimeToPosition(float time)
{
return time * PlaySettings.playSpeedMultiplier * Constants.SCROLL_MULT;
}
public static float PositionToTime(float pos)
{
return pos / PlaySettings.playSpeedMultiplier / Constants.SCROLL_MULT;
}
public static string DifficultyValueToString(float diffPoint)
{
return Mathf.FloorToInt(diffPoint).ToString() + (diffPoint > Mathf.Floor(diffPoint) ? "+" : "");