Menu song select: Switch ease function to Curve interp

This commit is contained in:
Luke Hubmayer-Werner 2021-01-12 01:03:47 +10:30
parent e0076be615
commit 843efb3f54
2 changed files with 10 additions and 7 deletions

View File

@ -1,10 +1,14 @@
[gd_scene load_steps=5 format=2]
[gd_scene load_steps=6 format=2]
[ext_resource path="res://scripts/ScoreText.gd" type="Script" id=1]
[ext_resource path="res://scripts/Menu.gd" type="Script" id=2]
[ext_resource path="res://shaders/menu.tres" type="Material" id=3]
[ext_resource path="res://shaders/scoretext.tres" type="Material" id=4]
[sub_resource type="Curve" id=1]
min_value = -1.0
_data = [ Vector2( -1, -1 ), 0.0, 0.0, 0, 0, Vector2( 0, 0 ), 2.0, 2.0, 1, 1, Vector2( 1, 1 ), 0.0, 0.0, 0, 0 ]
[node name="Menu" type="Control"]
material = ExtResource( 3 )
margin_left = -540.0
@ -18,6 +22,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
NoteHandlerPath = NodePath("../NoteHandler")
ease_curve = SubResource( 1 )
[node name="ScoreText" type="Node2D" parent="."]
material = ExtResource( 4 )

View File

@ -14,11 +14,9 @@ enum MenuMode {SONG_SELECT, CHART_SELECT, OPTIONS, GAMEPLAY, SCORE_SCREEN}
var selected_genre: int = 0
var selected_genre_vis: int = 0
var selected_genre_delta: float = 0.0 # For floaty display scrolling
var selected_genre_speed: float = 0.0 # For floaty display scrolling
var selected_song: int = 0
var selected_song_vis: int = 0
var selected_song_delta: float = 0.0 # For floaty display scrolling
var selected_song_speed: float = 0.0 # For floaty display scrolling
var selected_song_key: String = ''
var selected_difficulty = ChartDifficulty.ADV
var menu_mode = MenuMode.SONG_SELECT
@ -41,6 +39,8 @@ var ScoreFont := preload('res://assets/MenuScoreFont.tres')
var snd_interact := preload('res://assets/softclap.wav')
var snd_error := preload('res://assets/miss.wav')
export var ease_curve: Curve
func scan_library():
var results = FileLoader.scan_library()
genres = results.genres
@ -82,8 +82,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var diff = selected_song - (selected_song_vis + selected_song_delta)
selected_song_speed = ease(abs(diff), 1)*10
selected_song_delta += sign(diff) * selected_song_speed * delta
selected_song_delta += ease_curve.interpolate(clamp(diff, -2, 2)*0.5) * 10 * delta
if selected_song_delta > 0.5:
selected_song_delta -= 1.0
selected_song_vis += 1
@ -92,8 +91,7 @@ func _process(delta):
selected_song_vis -= 1
var g_diff = selected_genre - (selected_genre_vis + selected_genre_delta)
selected_genre_speed = ease(abs(g_diff), 1)*10
selected_genre_delta += sign(g_diff) * selected_genre_speed * delta
selected_genre_delta += ease_curve.interpolate(clamp(g_diff, -1, 1)) * 10 * delta
if selected_genre_delta > 0.5:
selected_genre_delta -= 1.0
selected_genre_vis += 1