Skip to content

Commit 560d062

Browse files
committed
Testing Chart Background Looping
Prototyping spacing and looping for chart.
1 parent 8fed186 commit 560d062

5 files changed

Lines changed: 148 additions & 0 deletions

File tree

project.godot

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ arrowRight={
5656
[rendering]
5757

5858
textures/canvas_textures/default_texture_filter=0
59+
60+
[threading]
61+
62+
worker_pool/canvas_textures/default_texture_filter=1

scenes/ChartViewport/ChartBg.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Godot;
2+
using System;
3+
4+
public partial class ChartBg : TextureRect
5+
{
6+
[Export] public float Bounds = 700f;
7+
[Export] public float Speed = 5;
8+
9+
10+
// Called every frame. 'delta' is the elapsed time since the previous frame.
11+
public override void _Process(double delta)
12+
{
13+
if (Position.X <= -Bounds)
14+
{
15+
Position = new Vector2(Bounds, Position.Y);
16+
}
17+
Position += Speed * Vector2.Left;
18+
19+
}
20+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Godot;
2+
using System;
3+
4+
//Lets say this inits all the initial notes and manages the chart BG.
5+
6+
//What does this do?
7+
//Input, visual looping, timing, battle stuff, combo, note creation
8+
9+
//Focus on the looping
10+
/*
11+
12+
This should manage creating sprites for notes???
13+
This should manage subview camera pos and zoom.
14+
15+
Movement should primarily be done from a parent node
16+
BackGround probably needs 2 sprites or parallax:
17+
Get a set length, based on viewport and loop/song length (Const PLAYWIDTH)
18+
Once one BG hits a certain left pos return it to the right pos
19+
20+
Notes are similar, but only need 1 representation.
21+
Once hits left bounds return to right bounds
22+
(Something else should probably manage refreshing, input, etc)
23+
Can probably use an object pool
24+
25+
If timing based input checking:
26+
This is enough, notes are visually just sprites
27+
Collision based - This might need to manage that, or have a sister manager that does, notes need more stuff on their own
28+
*/
29+
30+
public partial class ChartManager : SubViewportContainer
31+
{
32+
33+
//Simulated variables, remove later
34+
private const int Bpm = 120;
35+
private const double SongLength = 160; //secs
36+
37+
//Arbitrary vars, play with these
38+
private const double ChartLength = 1400;
39+
private const int NumLoops = 5; //TODO: Loops should be based on measures of a song?
40+
41+
//Nodes from scene
42+
[Export] public CanvasGroup ChartLoopables;
43+
44+
private double _loopLen; //secs
45+
private int _beatsPerLoop;
46+
47+
public override void _Ready()
48+
{
49+
_loopLen = SongLength / NumLoops;
50+
_beatsPerLoop = (int)(_loopLen / (60f / Bpm));
51+
52+
53+
}
54+
55+
public override void _Process(double delta)
56+
{
57+
//ChartLoopables.Position += 10 * Vector2.Left;
58+
}
59+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[gd_scene load_steps=4 format=3 uid="uid://dfevfib11kou1"]
2+
3+
[ext_resource type="Texture2D" uid="uid://b0tvsewgnf2x7" path="res://icon.svg" id="1_0wnka"]
4+
[ext_resource type="Script" path="res://scenes/ChartViewport/ChartManager.cs" id="1_ruh2l"]
5+
[ext_resource type="Script" path="res://scenes/ChartViewport/ChartBg.cs" id="3_runyu"]
6+
7+
[node name="VPContainer" type="SubViewportContainer" node_paths=PackedStringArray("ChartLoopables")]
8+
offset_right = 480.0
9+
offset_bottom = 220.0
10+
script = ExtResource("1_ruh2l")
11+
ChartLoopables = NodePath("SubViewport/ChartLoopables")
12+
13+
[node name="SubViewport" type="SubViewport" parent="."]
14+
handle_input_locally = false
15+
size = Vector2i(480, 220)
16+
render_target_update_mode = 4
17+
18+
[node name="Camera2D" type="Camera2D" parent="SubViewport"]
19+
position = Vector2(240, 110)
20+
21+
[node name="MockPlayhead" type="Sprite2D" parent="SubViewport"]
22+
modulate = Color(0, 0, 0, 0.615686)
23+
z_index = 1
24+
position = Vector2(60, 120)
25+
scale = Vector2(0.1, 2)
26+
texture = ExtResource("1_0wnka")
27+
28+
[node name="ChartLoopables" type="CanvasGroup" parent="SubViewport"]
29+
unique_name_in_owner = true
30+
31+
[node name="ChartBG1" type="TextureRect" parent="SubViewport/ChartLoopables"]
32+
modulate = Color(0.439216, 1, 1, 0.545098)
33+
offset_top = -46.0
34+
offset_right = 700.0
35+
offset_bottom = 254.0
36+
texture = ExtResource("1_0wnka")
37+
script = ExtResource("3_runyu")
38+
39+
[node name="ChartBG2" type="TextureRect" parent="SubViewport/ChartLoopables"]
40+
modulate = Color(0.439216, 1, 1, 0.545098)
41+
offset_left = 700.0
42+
offset_top = -46.0
43+
offset_right = 1400.0
44+
offset_bottom = 254.0
45+
texture = ExtResource("1_0wnka")
46+
script = ExtResource("3_runyu")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://b0mrgr7h0ty1y"]
2+
3+
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://scenes/ChartViewport/ChartViewport.tscn" id="1_1vh1u"]
4+
5+
[node name="TestScene" type="Node2D"]
6+
7+
[node name="SubViewport" parent="." instance=ExtResource("1_1vh1u")]
8+
offset_left = 80.0
9+
offset_top = 140.0
10+
offset_right = 560.0
11+
offset_bottom = 360.0
12+
13+
[node name="ColorRect" type="ColorRect" parent="."]
14+
z_index = -1
15+
offset_left = -70.0
16+
offset_top = -34.0
17+
offset_right = 673.0
18+
offset_bottom = 393.0
19+
color = Color(0.147672, 0.147672, 0.147672, 1)

0 commit comments

Comments
 (0)