[WIP] Smoothscroll refactor

This commit is contained in:
Luke Hubmayer-Werner 2019-11-25 15:15:04 +10:30
parent ad6f62fc38
commit a42781b8fd
1 changed files with 5 additions and 11 deletions

16
Menu.gd
View File

@ -9,7 +9,7 @@ enum ChartDifficulty {EASY, BASIC, ADV, EXPERT, MASTER}
var selected_genre: int = 0 var selected_genre: int = 0
var selected_song: int = 0 var selected_song: int = 0
var selected_song_delta: float = 0.0 # For floaty display scrolling var selected_song_delta: float = 0.0 # For floaty display scrolling
var selected_song_speed: float = 0.5 # For floaty display scrolling var selected_song_speed: float = 0.25 # For floaty display scrolling
var selected_difficulty = ChartDifficulty.ADV var selected_difficulty = ChartDifficulty.ADV
var TitleFont := preload("res://assets/MenuTitleFont.tres") var TitleFont := preload("res://assets/MenuTitleFont.tres")
@ -91,21 +91,15 @@ func _draw():
var scales = [] var scales = []
scales.resize(len(base_scales)*2-1) scales.resize(len(base_scales)*2-1)
if selected_song_delta >= 0.0: if selected_song_delta >= 0.0:
scales[0] = lerp(base_scales[0], base_scales[1], selected_song_delta)
for i in len(base_scales)-1: for i in len(base_scales)-1:
scales[i+1] = lerp(base_scales[i+1], base_scales[i], selected_song_delta) scales[i+1] = lerp(base_scales[i+1], base_scales[i], selected_song_delta)
for i in len(base_scales)-2: scales[-i] = lerp(base_scales[i], base_scales[i+1], selected_song_delta)
scales[-i-1] = lerp(base_scales[i+1], base_scales[i+2], selected_song_delta) scales[len(base_scales)] = base_scales[-1]
var i = len(base_scales)
scales[i] = base_scales[-1]
else: else:
scales[0] = lerp(base_scales[0], base_scales[1], -selected_song_delta)
for i in len(base_scales)-1: for i in len(base_scales)-1:
scales[i] = lerp(base_scales[i], base_scales[i+1], -selected_song_delta)
scales[-i-1] = lerp(base_scales[i+1], base_scales[i], -selected_song_delta) scales[-i-1] = lerp(base_scales[i+1], base_scales[i], -selected_song_delta)
for i in len(base_scales)-2: scales[-len(base_scales)] = base_scales[-1]
scales[i+1] = lerp(base_scales[i+1], base_scales[i+2], -selected_song_delta)
var i = len(base_scales)
scales[-i] = base_scales[-1]
var subsize = size * scales[0] var subsize = size * scales[0]
var gx = center_x - (subsize + spacer_x) * selected_song_delta var gx = center_x - (subsize + spacer_x) * selected_song_delta