From b59abba1b6c0eb4a97a990049e9e52ed0fd4e28a Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Tue, 29 Dec 2020 18:40:20 +1030 Subject: [PATCH] Less redundant array resizing on slides --- scripts/GameTheme.gd | 14 ++++++++------ scripts/NoteHandler.gd | 12 +++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/scripts/GameTheme.gd b/scripts/GameTheme.gd index 881c275..059dd2b 100644 --- a/scripts/GameTheme.gd +++ b/scripts/GameTheme.gd @@ -96,15 +96,17 @@ const COLOR_STAR := Color(0, 0, 1, 1) const COLOR_DOUBLE := Color(1, 1, 0, 1) # When two (or more in master) hit events coincide const COLOR_DOUBLE_MISS := Color(0.33, 0.33, 0, 1) const COLOR_TEXT := Color(1, 1, 1, 1) +const COLOR_SLIDE := Color(0.65, 0.65, 1.0, 1.0) +const COLOR_DOUBLE_SLIDE := Color(1.0, 1.0, 0.35, 1.0) const COLOR_DIFFICULTY := PoolColorArray([ # Background, foreground for each - Color(0.435, 0.333, 1.000), Color(1.0, 1.0, 1.0), - Color(0.150, 1.000, 0.275), Color(1.0, 1.0, 1.0), - Color(0.973, 0.718, 0.039), Color(1.0, 1.0, 1.0), - Color(1.000, 0.150, 0.150), Color(1.0, 1.0, 1.0), - Color(0.761, 0.271, 0.902), Color(1.0, 1.0, 1.0), + Color(0.435, 0.333, 1.000), Color.white, + Color(0.150, 1.000, 0.275), Color.white, + Color(0.973, 0.718, 0.039), Color.white, + Color(1.000, 0.150, 0.150), Color.white, + Color(0.761, 0.271, 0.902), Color.white, Color(1.0, 1.0, 1.0), Color(0.737, 0.188, 0.894), - Color(0.000, 0.000, 1.000), Color(1.0, 1.0, 1.0), + Color(0.000, 0.000, 1.000), Color.white, ]) const COLOR_ARRAY_TAP := PoolColorArray([COLOR_TAP, COLOR_TAP, COLOR_TAP, COLOR_TAP]) diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index 9bd9da5..5baf2cc 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -178,19 +178,17 @@ func make_slide_trail_mesh(note) -> ArrayMesh: var uvs := PoolVector2Array() var colors := PoolColorArray() var size := GameTheme.sprite_size2 - var color := Color(0.67, 0.67, 1.0) - if note.double_hit: - color = Color(1.0, 1.0, 0.35) + var color := GameTheme.COLOR_DOUBLE_SLIDE if note.double_hit else GameTheme.COLOR_SLIDE # First we need to determine how many arrows to leave. var trail_length : int = int(floor(note.get_slide_length() * slide_arrows_per_unit_length)) vertices.resize(3*trail_length) -# uvs.resize(3*trail_length) + uvs.resize(3*trail_length) colors.resize(3*trail_length) for i in trail_length: - uvs.append_array(GameTheme.UV_ARRAY_SLIDE_ARROW if i%3 else GameTheme.UV_ARRAY_SLIDE_ARROW2) + var u = GameTheme.UV_ARRAY_SLIDE_ARROW if i%3 else GameTheme.UV_ARRAY_SLIDE_ARROW2 for j in 3: -# uvs[i*3+j] = GameTheme.UV_ARRAY_SLIDE_ARROW[j] if i%2 else GameTheme.UV_ARRAY_SLIDE_ARROW2[j] + uvs[i*3+j] = u[j] colors[i*3+j] = Color(color.r, color.g, color.b, (1.0+float(i))/float(trail_length)) match note.slide_type: @@ -331,7 +329,7 @@ func touchbutton_released(col): check_hold_release(col) #---------------------------------------------------------------------------------------------------------------------------------------------- -var arr_div := Vector3(2.0, float(Rules.COLS), TAU) +const arr_div := Vector3(2.0, float(Rules.COLS), TAU) func _draw(): var mesh := ArrayMesh.new() var noteline_data : Image = noteline_array_image.get_rect(Rect2(0, 0, 16, 16))