First 3.2 update.

This commit is contained in:
Luke Hubmayer-Werner 2020-03-12 23:05:12 +10:30
parent 7db37acb36
commit 8088ea097d
12 changed files with 123 additions and 88 deletions

View File

@ -12,7 +12,7 @@ func arc_point_list(center: Vector2, radius: float, angle_from:=0.0, angle_to:=3
return point_list
func _draw():
var bezel_colors := PoolColorArray([GameTheme.bezel_color if not Engine.editor_hint else Color.red])
var bezel_colors := PoolColorArray([GameTheme.bezel_color])
var bezel_points: PoolVector2Array
var screen_size = $"/root".get_visible_rect().size

View File

@ -69,7 +69,7 @@ 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()
var receptor_color := Color.blue
var bezel_color := Color.black
var bezel_color := Color.black if not Engine.editor_hint else Color.red
var RADIAL_COL_ANGLES := PoolRealArray() # ideally const
var RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const

View File

@ -34,8 +34,11 @@ func _ready():
set_fingers(0)
# connect("button_pressed", self, "print_pressed")
$"/root".connect("size_changed", self, "resize")
$VsyncButton.connect("toggled", self, "update_vsync")
resize()
func update_vsync(setting: bool):
OS.vsync_enabled = setting
func print_pressed(col: int):
print("Pressed %d"%col)

30
Menu.gd
View File

@ -1,5 +1,6 @@
#tool
extends Node2D
#extends Node2D
extends Control
var song_defs = {}
var song_images = {}
@ -203,7 +204,7 @@ func _draw_song_select(center: Vector2) -> Array:
var subsize = size * scales[0]
var gx = center.x - (subsize + spacer_x) * selected_song_delta
var genre = genres.keys()[g]
draw_string_centered(GenreFont, Vector2(0, gy), genre)
draw_string_centered(GenreFont, Vector2(center.x, gy), genre)
var songslist = genres[genre]
var s = len(songslist)
var key = songslist[selected_song_vis % s]
@ -239,7 +240,7 @@ func _draw_chart_select(center: Vector2) -> Array:
touchrects.append({rect=r, chart_idx=diff})
x += size + spacer_x
draw_string_centered(TitleFont, Vector2(center.x, center.y+size+64), song_defs[song_key]["title"], Color(0.95, 0.95, 1.0))
touchrects.append({rect=Rect2(-450.0, 150.0, 900.0, 300.0), chart_idx=-1})
touchrects.append({rect=Rect2(center.x-450.0, center.y+310.0, 900.0, 300.0), chart_idx=-1})
return touchrects
func _draw_score_screen(center: Vector2) -> Array:
@ -329,19 +330,19 @@ func _draw_score_screen(center: Vector2) -> Array:
draw_string_centered(TitleFont, Vector2(x, y2+y_spacing*7), "Early : Late", Color(0.95, 0.95, 1.0))
draw_string_centered(TitleFont, Vector2(x, y2+y_spacing*8), "%3d%% : %3d%%"%[notecount_early*100/notecount_total, notecount_late*100/notecount_total], Color(0.95, 0.95, 1.0))
var rect_songselect := Rect2(-100.0, 300.0, 400.0, 100.0)
var rect_songselect := Rect2(x-100.0, y+660.0, 400.0, 100.0)
draw_rect(rect_songselect, Color.red)
draw_string_centered(TitleFont, Vector2(x+100, 320), "Song Select", Color(0.95, 0.95, 1.0))
draw_string_centered(TitleFont, Vector2(x+100, y+680), "Song Select", Color(0.95, 0.95, 1.0))
touchrects.append({rect=rect_songselect, next_menu=MenuMode.SONG_SELECT})
var rect_save := Rect2(-300.0, 300.0, 180.0, 100.0)
var rect_save := Rect2(x-300.0, y+660.0, 180.0, 100.0)
if not scorescreen_saved:
draw_rect(rect_save, Color.blue)
draw_string_centered(TitleFont, Vector2(x-210, 320), "Save", Color(0.95, 0.95, 1.0))
draw_string_centered(TitleFont, Vector2(x-210, y+680), "Save", Color(0.95, 0.95, 1.0))
touchrects.append({rect=rect_save, action="save"})
else:
draw_rect(rect_save, Color.darkgray)
draw_string_centered(TitleFont, Vector2(x-210, 320), "Saved", Color(0.95, 0.95, 1.0))
draw_string_centered(TitleFont, Vector2(x-210, y+680), "Saved", Color(0.95, 0.95, 1.0))
return touchrects
func _draw_gameplay(center: Vector2) -> Array:
@ -349,9 +350,9 @@ func _draw_gameplay(center: Vector2) -> Array:
var x = center.x
var y = center.y
var rect_songselect := Rect2(-960.0, 440.0, 100.0, 100.0)
var rect_songselect := Rect2(x-960.0, y+440.0, 100.0, 100.0)
draw_rect(rect_songselect, Color.red)
draw_string_centered(TitleFont, Vector2(-910, 470), "Stop", Color(0.95, 0.95, 1.0))
draw_string_centered(TitleFont, center+Vector2(-910, 470), "Stop", Color(0.95, 0.95, 1.0))
touchrects.append({rect=rect_songselect, action="stop"})
return touchrects
@ -360,15 +361,16 @@ func _draw():
var songs = len(song_defs)
var size = 216
var outline_px = 3
var center = Vector2(0.0, -160.0)
var center = Vector2(540.0, 540.0-160.0) # Vector2(0.0, -160.0)
touch_rects = []
$ScoreText.hide()
for i in MenuMode:
touch_rects.append([])
if menu_mode_prev_fade_timer > 0.0:
var progress = 1.0 - menu_mode_prev_fade_timer/menu_mode_prev_fade_timer_duration
var center_prev = lerp(center, Vector2(0.0, 900.0), progress)
var center_next = lerp(Vector2(0.0, -900.0), center, progress)
var center_prev = lerp(center, center+Vector2(0.0, 900.0), progress)
var center_next = lerp(center+Vector2(0.0, -900.0), center, progress)
match menu_mode_prev:
MenuMode.SONG_SELECT:
_draw_song_select(center_prev)
@ -391,6 +393,7 @@ func _draw():
GameTheme.set_screen_filter_alpha(1.0 - progress)
MenuMode.SCORE_SCREEN:
_draw_score_screen(center_next)
$ScoreText.show()
else:
match menu_mode:
MenuMode.SONG_SELECT:
@ -407,6 +410,7 @@ func _draw():
MenuMode.SCORE_SCREEN:
GameTheme.set_screen_filter_alpha(1.0)
touch_rects[menu_mode] = _draw_score_screen(center)
$ScoreText.show()
func set_menu_mode(mode):
menu_mode_prev = menu_mode

View File

@ -86,6 +86,7 @@ class NoteSlide extends NoteBase:
Note.SlideType.ARC_ACW:
var circle_angle : float = lerp(values.start_a, values.end_a, progress)
return polar2cartesian(GameTheme.receptor_ring_radius, circle_angle)
return Vector2(0.0, 0.0)
func get_angle(progress: float) -> float:
match slide_type:
@ -97,6 +98,7 @@ class NoteSlide extends NoteBase:
Note.SlideType.ARC_ACW:
var circle_angle : float = lerp(values.start_a, values.end_a, progress)
return circle_angle - PI/2.0
return 0.0
func get_slide_length() -> float:
# Return unit-circle (r=1) length of slide trail
@ -107,6 +109,7 @@ class NoteSlide extends NoteBase:
return fposmod(GameTheme.RADIAL_COL_ANGLES[column_release] - GameTheme.RADIAL_COL_ANGLES[column], TAU)
Note.SlideType.ARC_ACW:
return fposmod(GameTheme.RADIAL_COL_ANGLES[column] - GameTheme.RADIAL_COL_ANGLES[column_release], TAU)
return 0.0

View File

@ -575,6 +575,7 @@ func load_track(data: Dictionary, difficulty_idx: int):
meshinstance.material.set_shader_param("bps", bpm/60.0)
meshinstance.material.set_shader_param("screen_size", get_viewport().get_size())
meshinstance.set_texture(tex)
initialise_scores() # Remove old score
func stop():
$"/root/main/music".stop()
@ -620,12 +621,12 @@ func _process(delta):
for i in [-4.0, -3.0, -2.0, -1.0]:
var delay := real_time(i) - time
var timer = Timer.new()
add_child(timer)
timer.set_one_shot(false)
# timer.set_timer_process_mode(Timer.TIMER_PROCESS_FIXED)
timer.set_wait_time(delay)
timer.connect("timeout", self, "intro_click")
timer.start()
add_child(timer)
timer.connect("timeout", timer, "queue_free")
# if (t_old < 0) and (t >= 0):

View File

@ -1,4 +1,4 @@
#tool
tool
extends MeshInstance2D
var ring_px := 4 # Analogous to diameter
@ -7,6 +7,9 @@ var shadow_px := 8 # Outer edge, analogous to radius
var shadow_color := Color.black
var center := Vector2(0.0, 0.0)
var ring_vertex_count := 36
var ring_skew := 0.0
func make_ring_mesh(inner_vertices: int, thickness: float, radius: float, skew:=0.5, repeat_start:=true):
# This makes a trianglestrip around the ring, consisting of chords on the inside and tangents on the outside.
# The goal is to exchange some fragment and vertex processing load:
@ -91,10 +94,8 @@ func draw_tris():
var ring_vertices
func update_ring_mesh():
var mesh_v = $"../InputHandler/VerticesSlider".value
var skew = $"../InputHandler/SkewSlider".value
var ring_thickness = receptor_px + shadow_px*2
ring_vertices = make_ring_mesh(mesh_v, ring_thickness, GameTheme.receptor_ring_radius, skew)
ring_vertices = make_ring_mesh(ring_vertex_count, ring_thickness, GameTheme.receptor_ring_radius, ring_skew)
var temp_mesh = ArrayMesh.new()
var mesh_arrays = []
mesh_arrays.resize(Mesh.ARRAY_MAX)
@ -108,18 +109,16 @@ func update_ring_mesh():
func _draw():
# draw_old(true, true)
# draw_tris()
var mesh_v = $"../InputHandler/VerticesSlider".value
var skew = $"../InputHandler/SkewSlider".value
var mesh_v = ring_vertex_count
var ring_thickness = receptor_px + shadow_px*2
var estimated_area = circumscribe_polygon_area(GameTheme.receptor_ring_radius+ring_thickness*0.5, mesh_v) - inscribe_polygon_area(GameTheme.receptor_ring_radius-ring_thickness*0.5, mesh_v)
var ideal_ring_area = PI * (pow(GameTheme.receptor_ring_radius+receptor_px/2+shadow_px, 2) - pow(GameTheme.receptor_ring_radius-receptor_px/2-shadow_px, 2))
# var l = len(ring_vertices)
# for i in l:
# estimated_area += triangle_area(ring_vertices[i], ring_vertices[(i+1)%l], ring_vertices[(i+2)%l])
var quad_area = 4*pow(GameTheme.receptor_ring_radius+receptor_px/2+shadow_px, 2)
var fps = Performance.get_monitor(Performance.TIME_FPS)
$"/root/main/InputHandler".text = "Vertices: %d*2 Skew: %.3f\nArea: %.0f\n(%.0f%% ideal ring)\n(%.0f%% quad)\nFPS: %.0f"%[mesh_v, skew, estimated_area, 100.0*estimated_area/ideal_ring_area, 100.0*estimated_area/quad_area, fps]
var audio_latency = Performance.get_monitor(Performance.AUDIO_OUTPUT_LATENCY)
# $"/root/main/InputHandler".text = "Vertices: %d*2 Skew: %.3f\nArea: %.0f\n(%.0f%% ideal ring)\n(%.0f%% quad)\nFPS: %.0f"%[mesh_v, skew, estimated_area, 100.0*estimated_area/ideal_ring_area, 100.0*estimated_area/quad_area, fps]
$"/root/main/InputHandler".text = "FPS: %.0f\nAudio Latency: %.2fms"%[fps, audio_latency*1000]
material.set_shader_param("dot_radius", 0.5*receptor_px/GameTheme.receptor_ring_radius)
material.set_shader_param("line_thickness", 0.5*ring_px/GameTheme.receptor_ring_radius)
@ -127,8 +126,13 @@ func _draw():
material.set_shader_param("shadow_thickness_taper", -0.75)
material.set_shader_param("px", 0.5/GameTheme.receptor_ring_radius)
func update_ring_mesh_1arg(arg1):
# Hack because signals can't discard arguments when connected to smaller slots :(
func set_ring_vertex_count(num: int):
assert(num > 3)
ring_vertex_count = num
update_ring_mesh()
func set_ring_skew(skew: int):
ring_skew = skew
update_ring_mesh()
func _ready():
@ -144,8 +148,8 @@ func _ready():
material.set_shader_param("num_receptors", Rules.COLS)
update_ring_mesh()
$"../InputHandler/VerticesSlider".connect("value_changed", self, "update_ring_mesh_1arg")
$"../InputHandler/SkewSlider".connect("value_changed", self, "update_ring_mesh_1arg")
# $"../InputHandler/VerticesSlider".connect("value_changed", self, "set_ring_vertex_count")
# $"../InputHandler/SkewSlider".connect("value_changed", self, "set_ring_skew")
$"/root".connect("size_changed", self, "update")
func _process(delta):

113
main.tscn
View File

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=23 format=2]
[ext_resource path="res://main.gd" type="Script" id=1]
[ext_resource path="res://video.gd" type="Script" id=2]
@ -17,6 +17,7 @@
[ext_resource path="res://Bezel.gd" type="Script" id=15]
[ext_resource path="res://assets/NotoSans.tres" type="DynamicFont" id=16]
[ext_resource path="res://InputHandler.gd" type="Script" id=17]
[ext_resource path="res://assets/test/TIT FOR TAT.avi" type="VideoStream" id=18]
[sub_resource type="ShaderMaterial" id=1]
shader = ExtResource( 4 )
@ -30,14 +31,14 @@ shader_param/shadow_thickness = 0.01
shader_param/shadow_thickness_taper = 0.33
shader_param/px = 0.002
[sub_resource type="ShaderMaterial" id=3]
[sub_resource type="ShaderMaterial" id=2]
shader = ExtResource( 9 )
shader_param/bps = null
shader_param/star_color = null
shader_param/held_color = null
shader_param/screen_size = null
[sub_resource type="ShaderMaterial" id=2]
[sub_resource type="ShaderMaterial" id=3]
shader = ExtResource( 10 )
shader_param/line_color = Color( 0.8, 0.8, 1, 0.8 )
shader_param/line_color_double = Color( 1, 1, 0.6, 0.9 )
@ -61,6 +62,18 @@ __meta__ = {
"_edit_vertical_guides_": [ ]
}
[node name="VideoPlayer" type="VideoPlayer" parent="."]
visible = false
margin_left = -640.0
margin_top = -360.0
margin_right = 640.0
margin_bottom = 360.0
stream = ExtResource( 18 )
volume_db = -80.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="music" type="AudioStreamPlayer" parent="."]
[node name="video" type="VideoPlayer" parent="."]
@ -105,17 +118,26 @@ scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 8 )
[node name="meshinstance" type="MeshInstance2D" parent="NoteHandler/Viewport/Center"]
material = SubResource( 3 )
material = SubResource( 2 )
[node name="notelines" type="MeshInstance2D" parent="NoteHandler/Viewport/Center"]
material = SubResource( 2 )
material = SubResource( 3 )
[node name="Painter" type="Node2D" parent="NoteHandler"]
material = SubResource( 4 )
script = ExtResource( 11 )
[node name="Menu" type="Node2D" parent="."]
[node name="Menu" type="Control" parent="."]
margin_left = -540.0
margin_top = -540.0
margin_right = 540.0
margin_bottom = 540.0
rect_pivot_offset = Vector2( 540, 540 )
rect_clip_content = true
script = ExtResource( 12 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ScoreText" type="Node2D" parent="Menu"]
material = ExtResource( 13 )
@ -132,37 +154,40 @@ margin_bottom = 540.0
custom_fonts/font = ExtResource( 16 )
text = "Fingers on the screen:"
script = ExtResource( 17 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VerticesSlider" type="HSlider" parent="InputHandler"]
margin_left = 10.0
margin_top = 280.0
margin_right = 310.0
margin_bottom = 296.0
min_value = 3.0
max_value = 72.0
value = 36.0
tick_count = 2
ticks_on_borders = true
[node name="SkewSlider" type="HSlider" parent="InputHandler"]
margin_left = 10.0
margin_top = 310.0
margin_right = 310.0
margin_bottom = 320.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
max_value = 0.5
step = 0.01
tick_count = 3
ticks_on_borders = true
[node name="Label" type="Label" parent="InputHandler"]
margin_top = 136.0
margin_right = 116.0
margin_bottom = 150.0
text = "Subsampling (X, Y)"
[node name="SSXSlider" type="HSlider" parent="InputHandler"]
margin_left = 10.0
margin_top = 400.0
margin_top = 160.0
margin_right = 310.0
margin_bottom = 410.0
margin_bottom = 156.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
min_value = 0.1
max_value = 2.0
step = 0.01
value = 1.0
tick_count = 3
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SSYSlider" type="HSlider" parent="InputHandler"]
margin_left = 10.0
margin_top = 176.0
margin_right = 310.0
margin_bottom = 186.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
@ -174,18 +199,12 @@ value = 1.0
tick_count = 3
ticks_on_borders = true
[node name="SSYSlider" type="HSlider" parent="InputHandler"]
margin_left = 10.0
margin_top = 430.0
margin_right = 310.0
margin_bottom = 440.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
min_value = 0.1
max_value = 2.0
step = 0.01
value = 1.0
tick_count = 3
ticks_on_borders = true
[node name="VsyncButton" type="CheckButton" parent="InputHandler"]
margin_left = 4.0
margin_top = 90.0
margin_right = 121.0
margin_bottom = 130.0
text = "Vsync"
__meta__ = {
"_edit_use_anchors_": false
}

View File

@ -17,11 +17,11 @@ _global_script_class_icons={
config/name="Rhythm"
run/main_scene="res://main.tscn"
config/icon="res://icon.png"
config/icon="res://assets/spritesheet.png"
[audio]
output_latency=5
output_latency=4
channel_disable_threshold_db=-100.0
channel_disable_time=5.0
@ -36,7 +36,7 @@ SFXPlayer="*res://SFXPlayer.gd"
[debug]
gdscript/warnings/unused_variable=false
gdscript/warnings/unused_class_variable=false
gdscript/warnings/shadowed_variable=false
gdscript/warnings/unused_argument=false
gdscript/warnings/unused_signal=false
gdscript/warnings/return_value_discarded=false
@ -55,6 +55,7 @@ window/stretch/aspect="keep_height"
[gdnative]
singletons=[ "res://addons/videodecoder.gdnlib" ]
singletons_disabled=[ ]
[rendering]