From 14ebaf2f1eb6f54f58eeb02e732ab02439851861 Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Tue, 22 Dec 2020 23:07:46 +1030 Subject: [PATCH] Fix subsampling to be independent of screen resolution --- main.tscn | 12 ++++++------ scripts/GameTheme.gd | 8 ++++++++ scripts/NoteHandler.gd | 14 -------------- scripts/NoteViewport.gd | 7 ++++--- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/main.tscn b/main.tscn index cdef563..67a3182 100644 --- a/main.tscn +++ b/main.tscn @@ -184,10 +184,10 @@ grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 min_value = 0.1 -max_value = 2.0 -step = 0.01 +max_value = 1.0 +step = 0.05 value = 1.0 -tick_count = 3 +tick_count = 9 ticks_on_borders = true __meta__ = { "_edit_use_anchors_": false @@ -203,10 +203,10 @@ grow_vertical = 2 size_flags_horizontal = 3 size_flags_vertical = 3 min_value = 0.1 -max_value = 2.0 -step = 0.01 +max_value = 1.0 +step = 0.05 value = 1.0 -tick_count = 3 +tick_count = 9 ticks_on_borders = true __meta__ = { "_edit_use_anchors_": false diff --git a/scripts/GameTheme.gd b/scripts/GameTheme.gd index 7c10e88..859b509 100644 --- a/scripts/GameTheme.gd +++ b/scripts/GameTheme.gd @@ -132,6 +132,14 @@ const COLOR_ARRAY_DOUBLE_MISS_8 := PoolColorArray([ COLOR_DOUBLE_MISS, COLOR_DOUBLE_MISS, COLOR_DOUBLE_MISS, COLOR_DOUBLE_MISS ]) +# Normal vertex arrays for our sprites. Might be unnecessary? +const DEFAULT_NORMAL := Vector3(0, 0, 1) +const NORMAL_ARRAY_4 := PoolVector3Array([DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL]) +const NORMAL_ARRAY_8 := PoolVector3Array([ + DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, + DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL + ]) + var screen_filter_min_alpha := 0.2 var screen_filter := Color(0.0, 0.0, 0.0, screen_filter_min_alpha) signal screen_filter_changed() diff --git a/scripts/NoteHandler.gd b/scripts/NoteHandler.gd index 8c2ffc7..6d5ab0a 100644 --- a/scripts/NoteHandler.gd +++ b/scripts/NoteHandler.gd @@ -44,15 +44,6 @@ var slide_trail_mesh_instances := {} var noteline_array_image := Image.new() - -# Normal vertex arrays for our sprites. Might be unnecessary? -const DEFAULT_NORMAL := Vector3(0, 0, 1) -var NORMAL_ARRAY_4 := PoolVector3Array([DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL]) -var NORMAL_ARRAY_8 := PoolVector3Array([ - DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, - DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL - ]) - # Text UVs var text_UV_arrays := [] func make_text_UV(row: int, column: int) -> PoolVector2Array: @@ -125,7 +116,6 @@ func make_tap_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, color_arra var arrays = [] arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertex_array -# arrays[Mesh.ARRAY_NORMAL] = NORMAL_ARRAY_4 arrays[Mesh.ARRAY_TEX_UV] = GameTheme.UV_ARRAY_TAP arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) @@ -148,7 +138,6 @@ func make_hold_mesh(mesh: ArrayMesh, note_center: Vector2, note_center_rel: Vect var arrays = [] arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertex_array -# arrays[Mesh.ARRAY_NORMAL] = NORMAL_ARRAY_8 arrays[Mesh.ARRAY_TEX_UV] = GameTheme.UV_ARRAY_HOLD arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) @@ -166,7 +155,6 @@ func make_star_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, angle:=0. var arrays = [] arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertex_array -# arrays[Mesh.ARRAY_NORMAL] = NORMAL_ARRAY_4 arrays[Mesh.ARRAY_TEX_UV] = GameTheme.UV_ARRAY_STAR arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) @@ -175,7 +163,6 @@ func make_star_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, angle:=0. # var arrays = [] # arrays.resize(Mesh.ARRAY_MAX) # arrays[Mesh.ARRAY_VERTEX] = vertex_array -## arrays[Mesh.ARRAY_NORMAL] = NORMAL_ARRAY_4 # arrays[Mesh.ARRAY_TEX_UV] = UV_ARRAY_ARROW # arrays[Mesh.ARRAY_COLOR] = color_array # mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) @@ -481,7 +468,6 @@ func make_noteline_mesh_old() -> ArrayMesh: var arrays = [] arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertex_array_playfield - arrays[Mesh.ARRAY_NORMAL] = NORMAL_ARRAY_4 arrays[Mesh.ARRAY_TEX_UV] = uv_array_playfield mesh_playfield.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) return mesh_playfield diff --git a/scripts/NoteViewport.gd b/scripts/NoteViewport.gd index 17ebc2d..31935c6 100644 --- a/scripts/NoteViewport.gd +++ b/scripts/NoteViewport.gd @@ -1,16 +1,17 @@ extends Viewport func set_render_scale(scale: Vector2): - size = Vector2(1080, 1080) * scale + var ws = OS.window_size + var dim = min(ws.x, ws.y) + size = Vector2(dim, dim) * scale $Center.position = size * 0.5 - $Center.scale = scale + $Center.scale = size/1080 func slider_slot(arg1): set_render_scale(Vector2($"/root/main/InputHandler/SSXSlider".value, $"/root/main/InputHandler/SSYSlider".value)) # Called when the node enters the scene tree for the first time. func _ready(): -# set_render_scale(Vector2(0.5, 1.0)) $"/root/main/InputHandler/SSXSlider".connect("value_changed", self, "slider_slot") $"/root/main/InputHandler/SSYSlider".connect("value_changed", self, "slider_slot") slider_slot(1)