get background (hit area) animations working
This commit is contained in:
+3
-6
@@ -1,11 +1,10 @@
|
|||||||
[gd_scene load_steps=19 format=3 uid="uid://bqh00ot0csqmk"]
|
[gd_scene load_steps=18 format=3 uid="uid://bqh00ot0csqmk"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Play.cs" id="1_asytu"]
|
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Play.cs" id="1_asytu"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cyetvgmwnoy8l" path="res://Things/Background.tscn" id="2_8g6gv"]
|
[ext_resource type="PackedScene" uid="uid://cyetvgmwnoy8l" path="res://Things/Background.tscn" id="2_8g6gv"]
|
||||||
[ext_resource type="Shader" path="res://Shaders/Cutout2D.gdshader" id="3_rjbyl"]
|
[ext_resource type="Shader" path="res://Shaders/Cutout2D.gdshader" id="3_rjbyl"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/BGM.cs" id="4_c2dke"]
|
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/BGM.cs" id="4_c2dke"]
|
||||||
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/SFX.cs" id="5_owrd5"]
|
[ext_resource type="Script" path="res://Scripts/Scenes/Play/Audio/SFX.cs" id="5_owrd5"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cyopljug0duaa" path="res://Things/TunnelObjects/Notes/NoteTouch.tscn" id="6_kjmqf"]
|
|
||||||
|
|
||||||
[sub_resource type="Environment" id="Environment_nefjb"]
|
[sub_resource type="Environment" id="Environment_nefjb"]
|
||||||
ambient_light_source = 1
|
ambient_light_source = 1
|
||||||
@@ -62,7 +61,7 @@ uv1_scale = Vector3(-1, 1, 1)
|
|||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_w20vk"]
|
||||||
viewport_path = NodePath("Mask")
|
viewport_path = NodePath("Mask")
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_nh4gy"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_7nje4"]
|
||||||
resource_local_to_scene = true
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("3_rjbyl")
|
shader = ExtResource("3_rjbyl")
|
||||||
shader_parameter/mask = SubResource("ViewportTexture_w20vk")
|
shader_parameter/mask = SubResource("ViewportTexture_w20vk")
|
||||||
@@ -141,7 +140,7 @@ anchor_mode = 0
|
|||||||
editor_draw_screen = false
|
editor_draw_screen = false
|
||||||
|
|
||||||
[node name="Background" parent="2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")]
|
[node name="Background" parent="2D Viewport/Viewport Control" instance=ExtResource("2_8g6gv")]
|
||||||
material = SubResource("ShaderMaterial_nh4gy")
|
material = SubResource("ShaderMaterial_7nje4")
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
offset_top = -1920.0
|
offset_top = -1920.0
|
||||||
offset_right = 1920.0
|
offset_right = 1920.0
|
||||||
@@ -249,8 +248,6 @@ anchor_top = 1.0
|
|||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
grow_vertical = 0
|
grow_vertical = 0
|
||||||
|
|
||||||
[node name="NoteTouch" parent="2D Viewport/Viewport Control/Scroll Anchor/Notes Scroll" instance=ExtResource("6_kjmqf")]
|
|
||||||
|
|
||||||
[node name="AudioStreamPlayer BGM" type="AudioStreamPlayer" parent="."]
|
[node name="AudioStreamPlayer BGM" type="AudioStreamPlayer" parent="."]
|
||||||
script = ExtResource("4_c2dke")
|
script = ExtResource("4_c2dke")
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace WacK.Data.Chart
|
|||||||
public SortedList<float, List<NotePlay>> playNotes { get; private set; }
|
public SortedList<float, List<NotePlay>> playNotes { get; private set; }
|
||||||
public SortedList<float, NoteEvent<(int, int)>> timeSigChgs { get; private set; }
|
public SortedList<float, NoteEvent<(int, int)>> timeSigChgs { get; private set; }
|
||||||
public SortedList<float, NoteEvent<float>> tempoChgs { get; private set; }
|
public SortedList<float, NoteEvent<float>> tempoChgs { get; private set; }
|
||||||
public SortedList<float, NoteEvent<int>> events { get; private set; }
|
public SortedList<float, List<NoteEvent<int>>> events { get; private set; }
|
||||||
|
|
||||||
public Chart(string chartPath)
|
public Chart(string chartPath)
|
||||||
{
|
{
|
||||||
@@ -244,7 +244,6 @@ namespace WacK.Data.Chart
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// only add notes that aren't part of the hold
|
|
||||||
if (!playNotes.ContainsKey(curTime))
|
if (!playNotes.ContainsKey(curTime))
|
||||||
{
|
{
|
||||||
playNotes[curTime] = new List<NotePlay>();
|
playNotes[curTime] = new List<NotePlay>();
|
||||||
@@ -270,11 +269,15 @@ namespace WacK.Data.Chart
|
|||||||
this.timeSigChgs[curTime] = neii;
|
this.timeSigChgs[curTime] = neii;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoteEvent<int>
|
// NoteEvent<int> -- BG Change
|
||||||
var nei = curNote as NoteEvent<int>;
|
var nei = curNote as NoteEvent<int>;
|
||||||
if (nei != null)
|
if (nei != null)
|
||||||
{
|
{
|
||||||
this.events[curTime] = nei;
|
if (!events.ContainsKey(curTime))
|
||||||
|
{
|
||||||
|
events[curTime] = new List<NoteEvent<int>>();
|
||||||
|
}
|
||||||
|
events[curTime].Add(nei);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update previous states
|
// update previous states
|
||||||
|
|||||||
@@ -63,10 +63,14 @@ namespace WacK.Scenes
|
|||||||
public Viewport rightViewport;
|
public Viewport rightViewport;
|
||||||
|
|
||||||
private Chart chart;
|
private Chart chart;
|
||||||
|
// Indices point to the NEXT thing to look for. We process that thing once
|
||||||
|
// the song time is at or later than the thing's time.
|
||||||
|
private int chordNextIdx = 0;
|
||||||
|
private int eventNextIdx = 0;
|
||||||
|
|
||||||
// base scroll speed, which we can apply multipliers on
|
// base scroll speed, which we can apply multipliers on
|
||||||
public static readonly float BASE_PIXELS_PER_SECOND = 800;
|
public static readonly float BASE_PIXELS_PER_SECOND = 800;
|
||||||
public static float scrollPxPerSec
|
public static float ScrollPxPerSec
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -82,17 +86,19 @@ namespace WacK.Scenes
|
|||||||
|
|
||||||
// parse mer and create chart for current play
|
// parse mer and create chart for current play
|
||||||
chart = new(playParams.chartPath);
|
chart = new(playParams.chartPath);
|
||||||
RealizeChart();
|
InstantiateChartVisuals();
|
||||||
|
|
||||||
// audio setup
|
// // audio setup
|
||||||
bgmController.LoadFromUser(playParams.soundPath);
|
bgmController.LoadFromUser(playParams.soundPath);
|
||||||
bgmController.Play();
|
bgmController.Play();
|
||||||
|
|
||||||
|
// TestBGAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Instantiates necessary notes onto noteDisplay for the player to see.
|
/// Instantiates necessary notes onto noteDisplay for the player to see.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void RealizeChart()
|
private void InstantiateChartVisuals()
|
||||||
{
|
{
|
||||||
foreach (var msNote in chart.playNotes)
|
foreach (var msNote in chart.playNotes)
|
||||||
{
|
{
|
||||||
@@ -128,23 +134,78 @@ namespace WacK.Scenes
|
|||||||
}
|
}
|
||||||
nNote.Init(note);
|
nNote.Init(note);
|
||||||
var nPos = nNote.Position;
|
var nPos = nNote.Position;
|
||||||
nPos.Y = msNote.Key * -scrollPxPerSec;
|
nPos.Y = msNote.Key * -ScrollPxPerSec;
|
||||||
nNote.Position = nPos;
|
nNote.Position = nPos;
|
||||||
noteDisplay.AddChild(nNote);
|
noteDisplay.AddChild(nNote);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
/// <summary>
|
||||||
|
/// Process current game state. Should only run if playing a chart and unpaused.
|
||||||
|
/// </summary>
|
||||||
|
private void PlayLoop()
|
||||||
{
|
{
|
||||||
double time = bgmController.GetPlaybackPosition() + AudioServer.GetTimeSinceLastMix() - AudioServer.GetOutputLatency();
|
float time = bgmController.CurTime;
|
||||||
|
|
||||||
|
// check next event
|
||||||
|
while (eventNextIdx < chart.events.Count && time >= chart.events.Keys[eventNextIdx])
|
||||||
|
{
|
||||||
|
var t = chart.events.Keys[eventNextIdx];
|
||||||
|
var l = chart.events[t];
|
||||||
|
|
||||||
|
foreach (var e in l)
|
||||||
|
{
|
||||||
|
GD.Print($"Passed event {e.type}(pos={e.pos},size={e.size}) at {t}");
|
||||||
|
switch (e.type)
|
||||||
|
{
|
||||||
|
case NoteEventType.BGAdd:
|
||||||
|
background.SetSegments((int)e.pos, (int)e.size, true, (DrawDirection)e.value);
|
||||||
|
break;
|
||||||
|
case NoteEventType.BGRem:
|
||||||
|
background.SetSegments((int)e.pos, (int)e.size, false, (DrawDirection)e.value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eventNextIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set scroll
|
||||||
var nPos = noteDisplay.Position;
|
var nPos = noteDisplay.Position;
|
||||||
nPos.Y = bgmController.CurTime * scrollPxPerSec;
|
nPos.Y = time * ScrollPxPerSec;
|
||||||
noteDisplay.Position = nPos;
|
noteDisplay.Position = nPos;
|
||||||
scrollDisplay.Position = nPos;
|
scrollDisplay.Position = nPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void TestBGAnim()
|
||||||
|
{
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
|
||||||
|
// clockwise all
|
||||||
|
background.SetSegments(0, 60, true, DrawDirection.Clockwise);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
background.SetSegments(0, 60, false, DrawDirection.Clockwise);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
|
||||||
|
// counterclockwise all
|
||||||
|
background.SetSegments(0, 60, true, DrawDirection.CounterClockwise);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
background.SetSegments(0, 60, false, DrawDirection.CounterClockwise);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
|
||||||
|
// center all
|
||||||
|
background.SetSegments(0, 60, true, DrawDirection.Center);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
background.SetSegments(0, 60, false, DrawDirection.Center);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), SceneTreeTimer.SignalName.Timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
PlayLoop();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
playParams = null;
|
playParams = null;
|
||||||
|
|||||||
@@ -18,21 +18,22 @@ namespace WacK.Things.TunnelObjects
|
|||||||
public partial class Background : Node
|
public partial class Background : Node
|
||||||
{
|
{
|
||||||
[Export]
|
[Export]
|
||||||
private ColorRect firstSegment;
|
private TextureRect firstSegment;
|
||||||
private List<ColorRect> segments = new(60);
|
private List<TextureRect> segments = new(60);
|
||||||
|
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
var segmentsNode = FindChild("Segment Masks");
|
var segmentsNode = FindChild("Segment Masks");
|
||||||
|
firstSegment.Visible = false;
|
||||||
segments.Add(firstSegment);
|
segments.Add(firstSegment);
|
||||||
for (int i = 1; i < 60; ++i)
|
for (int i = 1; i < 60; ++i)
|
||||||
{
|
{
|
||||||
var n = (ColorRect)firstSegment.Duplicate();
|
var n = (TextureRect)firstSegment.Duplicate();
|
||||||
segmentsNode.AddChild(n);
|
segmentsNode.AddChild(n);
|
||||||
segments.Add(n);
|
segments.Add(n);
|
||||||
n.Name = i.ToString();
|
n.Name = i.ToString();
|
||||||
n.SetPosition(new Vector2(i * Constants.BASE_2D_RESOLUTION / 60, 0));
|
n.SetPosition(new Vector2(i * Constants.BASE_2D_RESOLUTION / 60, Constants.BASE_2D_RESOLUTION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ namespace WacK.Things.TunnelObjects
|
|||||||
// GD.Print($"{direction} = {state}. Even? {size % 2 == 0}");
|
// GD.Print($"{direction} = {state}. Even? {size % 2 == 0}");
|
||||||
|
|
||||||
double timer = 0;
|
double timer = 0;
|
||||||
double time = .5f;
|
double time = .1f;
|
||||||
|
|
||||||
int centerSeg = pos + size/2;
|
int centerSeg = pos + size/2;
|
||||||
while (timer < time)
|
while (timer < time)
|
||||||
@@ -79,6 +80,7 @@ namespace WacK.Things.TunnelObjects
|
|||||||
}
|
}
|
||||||
await ToSignal(GetTree(), "process_frame");
|
await ToSignal(GetTree(), "process_frame");
|
||||||
}
|
}
|
||||||
|
GD.Print("Finished BG anim!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace WacK.Things.TunnelObjects
|
|||||||
{
|
{
|
||||||
longThing = new Node2D();
|
longThing = new Node2D();
|
||||||
holdScroll.AddChild(longThing);
|
holdScroll.AddChild(longThing);
|
||||||
longThing.Position = new Vector2(0, (float)-holdNoteData.time * Play.scrollPxPerSec);
|
longThing.Position = new Vector2(0, (float)-holdNoteData.time * Play.ScrollPxPerSec);
|
||||||
|
|
||||||
if (holdNoteData.points.Count > 0)
|
if (holdNoteData.points.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,7 @@ namespace WacK.Things.TunnelObjects
|
|||||||
float segmentPos = 0;
|
float segmentPos = 0;
|
||||||
foreach (var (_, curNote) in holdNoteData.points)
|
foreach (var (_, curNote) in holdNoteData.points)
|
||||||
{
|
{
|
||||||
var curLength = Play.scrollPxPerSec * (float)(curNote.time - lastHold.time);
|
var curLength = Play.ScrollPxPerSec * (float)(curNote.time - lastHold.time);
|
||||||
var segment = CreateSegment(lastHold, curNote);
|
var segment = CreateSegment(lastHold, curNote);
|
||||||
longThing.AddChild(segment);
|
longThing.AddChild(segment);
|
||||||
segment.Position = new Vector2(0, segmentPos);
|
segment.Position = new Vector2(0, segmentPos);
|
||||||
@@ -50,7 +50,7 @@ namespace WacK.Things.TunnelObjects
|
|||||||
{
|
{
|
||||||
float minuteSize = Constants.BASE_2D_RESOLUTION / 60;
|
float minuteSize = Constants.BASE_2D_RESOLUTION / 60;
|
||||||
|
|
||||||
var length = Play.scrollPxPerSec * (float)(destination.time - origin.time);
|
var length = Play.ScrollPxPerSec * (float)(destination.time - origin.time);
|
||||||
var verts = new Vector2[4];
|
var verts = new Vector2[4];
|
||||||
|
|
||||||
int originPos;
|
int originPos;
|
||||||
|
|||||||
@@ -7,9 +7,6 @@ void fragment( )
|
|||||||
vec4 mask_color = texture(mask, UV).rgba;
|
vec4 mask_color = texture(mask, UV).rgba;
|
||||||
vec4 sprite_color = texture(TEXTURE, UV).rgba;
|
vec4 sprite_color = texture(TEXTURE, UV).rgba;
|
||||||
|
|
||||||
if (mask_color.a == 0.0)
|
sprite_color.a = mask_color.a;
|
||||||
{
|
|
||||||
sprite_color.a = 0.0;
|
|
||||||
}
|
|
||||||
COLOR = sprite_color;
|
COLOR = sprite_color;
|
||||||
}
|
}
|
||||||
+23
-5
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=10 format=3 uid="uid://cyetvgmwnoy8l"]
|
[gd_scene load_steps=12 format=3 uid="uid://cyetvgmwnoy8l"]
|
||||||
|
|
||||||
[ext_resource type="Shader" path="res://Shaders/Cutout2D.gdshader" id="1_f6ion"]
|
[ext_resource type="Shader" path="res://Shaders/Cutout2D.gdshader" id="1_f6ion"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dkohutwp0yujj" path="res://_Assets/Textures/HitLine/BGLine.png" id="1_w0gbp"]
|
[ext_resource type="Texture2D" uid="uid://dkohutwp0yujj" path="res://_Assets/Textures/HitLine/BGLine.png" id="1_w0gbp"]
|
||||||
@@ -22,12 +22,22 @@ shader_parameter/mask = SubResource("ViewportTexture_oigfv")
|
|||||||
|
|
||||||
[sub_resource type="Gradient" id="Gradient_djnn4"]
|
[sub_resource type="Gradient" id="Gradient_djnn4"]
|
||||||
offsets = PackedFloat32Array(0)
|
offsets = PackedFloat32Array(0)
|
||||||
colors = PackedColorArray(0.0308856, 0.0596563, 0.141577, 0.894118)
|
colors = PackedColorArray(0.0313726, 0.0588235, 0.141176, 1)
|
||||||
|
|
||||||
[sub_resource type="GradientTexture1D" id="GradientTexture1D_kn5i7"]
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_kn5i7"]
|
||||||
gradient = SubResource("Gradient_djnn4")
|
gradient = SubResource("Gradient_djnn4")
|
||||||
width = 2048
|
width = 2048
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_n1451"]
|
||||||
|
interpolation_mode = 2
|
||||||
|
interpolation_color_space = 2
|
||||||
|
offsets = PackedFloat32Array(0, 0.376518)
|
||||||
|
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_pibib"]
|
||||||
|
gradient = SubResource("Gradient_n1451")
|
||||||
|
width = 1920
|
||||||
|
|
||||||
[node name="Background" type="Control" node_paths=PackedStringArray("firstSegment")]
|
[node name="Background" type="Control" node_paths=PackedStringArray("firstSegment")]
|
||||||
material = SubResource("ShaderMaterial_h3xxm")
|
material = SubResource("ShaderMaterial_h3xxm")
|
||||||
custom_minimum_size = Vector2(1920, 1920)
|
custom_minimum_size = Vector2(1920, 1920)
|
||||||
@@ -47,6 +57,7 @@ offset_right = 40.0
|
|||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
|
|
||||||
[node name="SubViewport" type="SubViewport" parent="FullBG"]
|
[node name="SubViewport" type="SubViewport" parent="FullBG"]
|
||||||
|
transparent_bg = true
|
||||||
handle_input_locally = false
|
handle_input_locally = false
|
||||||
size = Vector2i(1920, 1920)
|
size = Vector2i(1920, 1920)
|
||||||
render_target_update_mode = 4
|
render_target_update_mode = 4
|
||||||
@@ -66,8 +77,11 @@ layout_mode = 1
|
|||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
|
offset_top = 1920.0
|
||||||
|
offset_bottom = 1920.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
rotation = -1.5708
|
||||||
texture = SubResource("GradientTexture1D_kn5i7")
|
texture = SubResource("GradientTexture1D_kn5i7")
|
||||||
expand_mode = 1
|
expand_mode = 1
|
||||||
|
|
||||||
@@ -114,6 +128,10 @@ expand_mode = 1
|
|||||||
transparent_bg = true
|
transparent_bg = true
|
||||||
size = Vector2i(1920, 1920)
|
size = Vector2i(1920, 1920)
|
||||||
|
|
||||||
[node name="0" type="ColorRect" parent="Segment Masks"]
|
[node name="0" type="TextureRect" parent="Segment Masks"]
|
||||||
offset_right = 32.0
|
anchors_preset = -1
|
||||||
offset_bottom = 1920.0
|
offset_top = 1920.0
|
||||||
|
offset_right = 1920.0
|
||||||
|
offset_bottom = 1952.0
|
||||||
|
rotation = -1.5708
|
||||||
|
texture = SubResource("GradientTexture1D_pibib")
|
||||||
|
|||||||
Reference in New Issue
Block a user