From b8502e6f02e3960108773a174a8fe46fe20825cb Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Tue, 19 Nov 2019 00:17:48 +1030 Subject: [PATCH] Basic input handling and judgement text --- Bezel.gd | 6 +- theme.gd => GameTheme.gd | 18 +++++- InputHandler.gd | 77 +++++++++++++++++++++--- Note.gd | 22 +++---- NoteHandler.gd | 122 +++++++++++++++++++++++++++------------ Receptors.gd | 10 ++-- main.tscn | 29 ++++++---- project.godot | 2 +- 8 files changed, 207 insertions(+), 79 deletions(-) rename theme.gd => GameTheme.gd (79%) diff --git a/Bezel.gd b/Bezel.gd index 9a43d20..814e794 100644 --- a/Bezel.gd +++ b/Bezel.gd @@ -4,12 +4,12 @@ extends "res://main.gd" var center := Vector2(0.0, 0.0) func _draw(): - var bezel_colors := PoolColorArray([theme.bezel_color]) + var bezel_colors := PoolColorArray([GameTheme.bezel_color]) var bezel_points: PoolVector2Array var screen_height2 := screen_height/2.0 - draw_rect(Rect2(-screen_height2, -screen_height2, -x_margin, screen_height), theme.bezel_color) - draw_rect(Rect2(screen_height2, -screen_height2, x_margin, screen_height), theme.bezel_color) + draw_rect(Rect2(-screen_height2, -screen_height2, -x_margin, screen_height), GameTheme.bezel_color) + draw_rect(Rect2(screen_height2, -screen_height2, x_margin, screen_height), GameTheme.bezel_color) bezel_points = arc_point_list(center, screen_height2, 0, -90) bezel_points.push_back(Vector2(screen_height2, -screen_height2)) diff --git a/theme.gd b/GameTheme.gd similarity index 79% rename from theme.gd rename to GameTheme.gd index c2b5ee2..9295f02 100644 --- a/theme.gd +++ b/GameTheme.gd @@ -1,6 +1,6 @@ extends Node -var receptor_ring_radius := 460 +var receptor_ring_radius := 460.0 var note_forecast_beats := 2.0 # Notes start to appear this many beats before you need to tap them const INNER_NOTE_CIRCLE_RATIO := 0.3 # Notes under this far from the center will zoom into existence const SLIDE_DELAY := 0.5 # Time in beats between the tap of the star and the start of the visual slide @@ -8,6 +8,14 @@ const SLIDE_DELAY := 0.5 # Time in beats between the tap of the star and the st var sprite_size := 128 var sprite_size2 := sprite_size/2 +var judge_text_size := 256 +# Text is rendered from center. +const JUDGE_TEXT_ANG2 := atan(1.0/4.0) +const JUDGE_TEXT_ANG1 := PI - JUDGE_TEXT_ANG2 +const JUDGE_TEXT_ANG3 := PI + JUDGE_TEXT_ANG2 +const JUDGE_TEXT_ANG4 := -JUDGE_TEXT_ANG2 +var judge_text_size2 := 0.5*judge_text_size/cos(JUDGE_TEXT_ANG2) + # Color definitions const COLOR_TAP := Color(1, 0.15, 0.15, 1) const COLOR_TAP2 := Color(0.75, 0.5, 0, 1) # High-score taps ("breaks" in maimai) @@ -15,6 +23,7 @@ const COLOR_HOLD := Color(1, 0.15, 0.15, 1) const COLOR_HOLD_HELD := Color(1, 1, 1, 1) 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_TEXT := Color(1, 1, 1, 1) var COLOR_ARRAY_TAP := PoolColorArray([COLOR_TAP, COLOR_TAP, COLOR_TAP, COLOR_TAP]) var COLOR_ARRAY_TAP2 := PoolColorArray([COLOR_TAP2, COLOR_TAP2, COLOR_TAP2, COLOR_TAP2]) @@ -44,4 +53,9 @@ func init_radial_values(): for i in range(Rules.COLS): var angle = deg2rad(fmod(Rules.FIRST_COLUMN_ANGLE_DEG + (i * Rules.COLS_ANGLE_DEG), 360.0)) RADIAL_COL_ANGLES.push_back(angle) - RADIAL_UNIT_VECTORS.push_back(Vector2(cos(angle), sin(angle))) \ No newline at end of file + RADIAL_UNIT_VECTORS.push_back(Vector2(cos(angle), sin(angle))) + + +func color_array_text(alpha: float) -> PoolColorArray: + var color := Color(COLOR_TEXT.r, COLOR_TEXT.g, COLOR_TEXT.b, alpha) + return PoolColorArray([color, color, color, color]) diff --git a/InputHandler.gd b/InputHandler.gd index 5cbf48e..07f5ea9 100644 --- a/InputHandler.gd +++ b/InputHandler.gd @@ -6,14 +6,32 @@ var fingers = 0 setget set_fingers # setter for show fingers number on scree var txt_ball = preload("res://assets/ball.png") # preload our ball texture var default_font = preload("res://assets/NotoSans.tres") # point to godot standard font - +var buttons_pressed := PoolByteArray() +var touchbuttons_pressed := PoolByteArray() +signal button_pressed(index) # Add int type to these once Godot supports typed signals +signal button_released(index) +signal touchbutton_pressed(index) +signal touchbutton_released(index) +const TOUCHBUTTON_MIN_DIST := 0.8 +const TOUCHBUTTON_MAX_DIST := 1.05 +const BUTTON_MIN_DIST := TOUCHBUTTON_MAX_DIST +const BUTTON_MAX_DIST := 1.25 func _init(): - pass + buttons_pressed.resize(Rules.COLS) + touchbuttons_pressed.resize(Rules.COLS) + for i in Rules.COLS: + buttons_pressed[i] = 0 + touchbuttons_pressed[i] = 0 func _ready(): set_process_unhandled_input(true) # process user input set_fingers(0) + connect("button_pressed", self, "print_pressed") + + +func print_pressed(col: int): + print("Pressed %d"%col) ########################################################################## @@ -26,6 +44,7 @@ func _draw(): # DRAW POINTS ################################################ draw_texture(txt_ball, point.position - Vector2(24, 24)) draw_string(default_font, point.position - Vector2(24, 24), str(i)) + draw_string(default_font, point.position + Vector2(-24, 48), str(point.position)) # if len(touch_positions) > 1: # for i in range(len(touch_positions)-1): # # Draw line @@ -35,6 +54,35 @@ func update_data(): touch_positions.clear() for i in touch_points: touch_positions.push_back(touch_points[i].position) + + + var buttons_pressed_temp := [] + var touchbuttons_pressed_temp := [] + for i in Rules.COLS: + buttons_pressed_temp.append(false) + touchbuttons_pressed_temp.append(false) + + for pos in touch_positions: + pos -= Vector2(960, 540) # Change this if we move the node + var pol = cartesian2polar(pos.x, pos.y) + var dist = pol.x/GameTheme.receptor_ring_radius + var angle = rad2deg(pol.y) + if dist < TOUCHBUTTON_MIN_DIST: + continue + # bin the angle + angle -= Rules.FIRST_COLUMN_ANGLE_DEG - Rules.COLS_TOUCH_ARC_DEG/2.0 + if fmod(angle, Rules.COLS_ANGLE_DEG) > Rules.COLS_TOUCH_ARC_DEG: + continue + var col := int(floor(angle/Rules.COLS_ANGLE_DEG)) + if dist < TOUCHBUTTON_MAX_DIST: + touchbuttons_pressed_temp[col] = true + elif dist < BUTTON_MAX_DIST: + buttons_pressed_temp[col] = true + + for i in Rules.COLS: + set_button_state(i, buttons_pressed_temp[i]) + set_touchbutton_state(i, touchbuttons_pressed_temp[i]) + set_fingers(len(touch_positions)) update() @@ -58,8 +106,23 @@ func _input(event): ########################################################################## # write how many fingers are tapping the screen func set_fingers(value): - fingers = value - if fingers > 0: - set_text("Fingers: " + str(fingers)) - else: - set_text("Fingers: 0") \ No newline at end of file + fingers = max(value, 0) + set_text("Fingers: %d" % fingers) + +func set_button_state(index: int, state: bool): + var new_state = int(state) + match new_state - buttons_pressed[index]: + 1: + emit_signal("button_pressed", index) + -1: + emit_signal("button_released", index) + buttons_pressed[index] = new_state + +func set_touchbutton_state(index: int, state: bool): + var new_state = int(state) + match new_state - touchbuttons_pressed[index]: + 1: + emit_signal("touchbutton_pressed", index) + -1: + emit_signal("touchbutton_released", index) + touchbuttons_pressed[index] = new_state diff --git a/Note.gd b/Note.gd index 1f99c59..872814d 100644 --- a/Note.gd +++ b/Note.gd @@ -36,17 +36,17 @@ class NoteSlide extends NoteBase: func update_slide_variables(): match slide_type: Note.SlideType.CHORD: - values.start = theme.RADIAL_UNIT_VECTORS[column] * theme.receptor_ring_radius - values.end = theme.RADIAL_UNIT_VECTORS[column_release] * theme.receptor_ring_radius + values.start = GameTheme.RADIAL_UNIT_VECTORS[column] * GameTheme.receptor_ring_radius + values.end = GameTheme.RADIAL_UNIT_VECTORS[column_release] * GameTheme.receptor_ring_radius values.angle = (values.end - values.start).angle() Note.SlideType.ARC_CW: - values.start_a = theme.RADIAL_COL_ANGLES[column] - values.end_a = theme.RADIAL_COL_ANGLES[column_release] + values.start_a = GameTheme.RADIAL_COL_ANGLES[column] + values.end_a = GameTheme.RADIAL_COL_ANGLES[column_release] if values.end_a < values.start_a: values.end_a += TAU Note.SlideType.ARC_ACW: - values.start_a = theme.RADIAL_COL_ANGLES[column] - values.end_a = theme.RADIAL_COL_ANGLES[column_release] + values.start_a = GameTheme.RADIAL_COL_ANGLES[column] + values.end_a = GameTheme.RADIAL_COL_ANGLES[column_release] if values.end_a > values.start_a: values.end_a -= TAU @@ -56,10 +56,10 @@ class NoteSlide extends NoteBase: return lerp(values.start, values.end, progress) Note.SlideType.ARC_CW: var circle_angle : float = lerp(values.start_a, values.end_a, progress) - return polar2cartesian(theme.receptor_ring_radius, circle_angle) + return polar2cartesian(GameTheme.receptor_ring_radius, circle_angle) Note.SlideType.ARC_ACW: var circle_angle : float = lerp(values.start_a, values.end_a, progress) - return polar2cartesian(theme.receptor_ring_radius, circle_angle) + return polar2cartesian(GameTheme.receptor_ring_radius, circle_angle) func get_angle(progress: float) -> float: match slide_type: @@ -76,11 +76,11 @@ class NoteSlide extends NoteBase: # Return unit-circle (r=1) length of slide trail match slide_type: Note.SlideType.CHORD: - return 2*abs(sin((theme.RADIAL_COL_ANGLES[column_release] - theme.RADIAL_COL_ANGLES[column])/2)) + return 2*abs(sin((GameTheme.RADIAL_COL_ANGLES[column_release] - GameTheme.RADIAL_COL_ANGLES[column])/2)) Note.SlideType.ARC_CW: - return fposmod(theme.RADIAL_COL_ANGLES[column_release] - theme.RADIAL_COL_ANGLES[column], TAU) + return fposmod(GameTheme.RADIAL_COL_ANGLES[column_release] - GameTheme.RADIAL_COL_ANGLES[column], TAU) Note.SlideType.ARC_ACW: - return fposmod(theme.RADIAL_COL_ANGLES[column] - theme.RADIAL_COL_ANGLES[column_release], TAU) + return fposmod(GameTheme.RADIAL_COL_ANGLES[column] - GameTheme.RADIAL_COL_ANGLES[column_release], TAU) diff --git a/NoteHandler.gd b/NoteHandler.gd index 2c3d83b..7e13462 100644 --- a/NoteHandler.gd +++ b/NoteHandler.gd @@ -2,19 +2,20 @@ extends "res://main.gd" # This script will draw all note events. -var tex := preload("res://assets/spritesheet-1024.png") -var tex_slide_arrow := preload("res://assets/slide-arrow-512.png") +var tex := preload("res://assets/spritesheet-4k.png") +var tex_judgement_text := preload("res://assets/text-4k.png") +var tex_slide_arrow := preload("res://assets/slide-arrow-4k.png") var slide_trail_shadermaterial := preload("res://shaders/slidetrail.tres") ## Constants for the overall notefield -#var theme.RADIAL_COL_ANGLES := PoolRealArray() # ideally const -#var theme.RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const +#var GameTheme.RADIAL_COL_ANGLES := PoolRealArray() # ideally const +#var GameTheme.RADIAL_UNIT_VECTORS := PoolVector2Array() # ideally const # #func init_radial_values(): # for i in range(Rules.COLS): # var angle = deg2rad(fmod(Rules.FIRST_COLUMN_ANGLE_DEG + (i * Rules.COLS_ANGLE_DEG), 360.0)) -# theme.RADIAL_COL_ANGLES.push_back(angle) -# theme.RADIAL_UNIT_VECTORS.push_back(Vector2(cos(angle), sin(angle))) +# GameTheme.RADIAL_COL_ANGLES.push_back(angle) +# GameTheme.RADIAL_UNIT_VECTORS.push_back(Vector2(cos(angle), sin(angle))) const SQRT2 := sqrt(2) const DEG45 := deg2rad(45.0) @@ -54,10 +55,42 @@ var NORMAL_ARRAY_8 := PoolVector3Array([ DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL, DEFAULT_NORMAL ]) +# Text UVs +var text_UV_arrays := [] +func make_text_UV(row: int, column: int) -> PoolVector2Array: + return PoolVector2Array([Vector2(column/4.0, row/8.0), Vector2((column+1)/4.0, row/8.0), Vector2(column/4.0, (row+1)/8.0), Vector2((column+1)/4.0, (row+1)/8.0)]) +func make_text_UVs(): + for row in 8: + for column in 4: + text_UV_arrays.append(make_text_UV(row, column)) +enum TextStyle {STRAIGHT=0, ARC=1, ARC_EARLY=2, ARC_LATE=3} +enum TextWord {NICE=0, OK=4, NG=8, PERFECT=12, GREAT=16, GOOD=20, ALMOST=24, MISS=28} + +func make_text_mesh(mesh: ArrayMesh, text_id: int, pos: Vector2, angle: float, alpha:=1.0, scale:=1.0): + var r := GameTheme.judge_text_size2 * scale + var vertex_array := PoolVector2Array([ + pos+polar2cartesian(r, angle+GameTheme.JUDGE_TEXT_ANG2), # TODO: fix this UV/vertex order mess + pos+polar2cartesian(r, angle+GameTheme.JUDGE_TEXT_ANG1), + pos+polar2cartesian(r, angle+GameTheme.JUDGE_TEXT_ANG4), + pos+polar2cartesian(r, angle+GameTheme.JUDGE_TEXT_ANG3) + ]) + var arrays = [] + arrays.resize(Mesh.ARRAY_MAX) + arrays[Mesh.ARRAY_VERTEX] = vertex_array + arrays[Mesh.ARRAY_TEX_UV] = text_UV_arrays[text_id] + arrays[Mesh.ARRAY_COLOR] = GameTheme.color_array_text(alpha) + mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) + +func make_judgement_text(mesh: ArrayMesh, text_id: int, col: int, progress:=0.0): + make_text_mesh(mesh, text_id, + GameTheme.RADIAL_UNIT_VECTORS[col] * GameTheme.receptor_ring_radius * lerp(0.85, 0.8, progress), + GameTheme.RADIAL_COL_ANGLES[col]-PI/2.0, lerp(1.0, 0.0, progress), lerp(1.0, 0.5, progress) + ) + # ---------------------------------------------------------------------------------------------------------------------------------------------------- # Helper functions to generate meshes from vertex arrays -func make_tap_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, color_array:=theme.COLOR_ARRAY_TAP): - var dim = theme.sprite_size2 * scale +func make_tap_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, color_array:=GameTheme.COLOR_ARRAY_TAP): + var dim = GameTheme.sprite_size2 * scale var vertex_array = PoolVector2Array([note_center + Vector2(-dim, -dim), note_center + Vector2(dim, -dim), note_center + Vector2(-dim, dim), note_center + Vector2(dim, dim)]) var arrays = [] arrays.resize(Mesh.ARRAY_MAX) @@ -67,8 +100,8 @@ func make_tap_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, color_arra arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) -func make_hold_mesh(mesh: ArrayMesh, note_center: Vector2, note_center_rel: Vector2, scale:=1.0, angle:=0.0, color_array = theme.COLOR_ARRAY_HOLD): - var dim = theme.sprite_size2 * scale +func make_hold_mesh(mesh: ArrayMesh, note_center: Vector2, note_center_rel: Vector2, scale:=1.0, angle:=0.0, color_array = GameTheme.COLOR_ARRAY_HOLD): + var dim = GameTheme.sprite_size2 * scale var dim2 = dim * SQRT2 var a1 = angle - DEG45 var a2 = angle + DEG45 @@ -90,8 +123,8 @@ func make_hold_mesh(mesh: ArrayMesh, note_center: Vector2, note_center_rel: Vect arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) -func make_star_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, angle:=0.0, color_array:=theme.COLOR_ARRAY_STAR): - var dim = theme.sprite_size2 * scale * SQRT2 +func make_star_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, angle:=0.0, color_array:=GameTheme.COLOR_ARRAY_STAR): + var dim = GameTheme.sprite_size2 * scale * SQRT2 var a1 = angle - DEG45 var a2 = angle + DEG45 var a3 = angle - DEG135 @@ -108,7 +141,7 @@ func make_star_mesh(mesh: ArrayMesh, note_center: Vector2, scale:=1.0, angle:=0. arrays[Mesh.ARRAY_COLOR] = color_array mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLE_STRIP, arrays) -#func make_arrow_mesh(mesh: ArrayMesh, vertex_array, color_array = theme.COLOR_ARRAY_TAP): +#func make_arrow_mesh(mesh: ArrayMesh, vertex_array, color_array = GameTheme.COLOR_ARRAY_TAP): # var arrays = [] # arrays.resize(Mesh.ARRAY_MAX) # arrays[Mesh.ARRAY_VERTEX] = vertex_array @@ -127,7 +160,7 @@ func make_slide_trail_mesh(note) -> ArrayMesh: var vertices := PoolVector2Array() var uvs := PoolVector2Array() var colors := PoolColorArray() - var size := theme.sprite_size2 + 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) @@ -180,7 +213,8 @@ func make_slide_trail_mesh(note) -> ArrayMesh: func _init(): Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN) - theme.init_radial_values() + GameTheme.init_radial_values() + make_text_UVs() func _draw(): var mesh := ArrayMesh.new() @@ -190,40 +224,40 @@ func _draw(): var j := 0 for note in active_notes: - var position : float = (t+theme.note_forecast_beats-note.time_hit)/theme.note_forecast_beats + var position : float = (t+GameTheme.note_forecast_beats-note.time_hit)/GameTheme.note_forecast_beats var scale := 1.0 - noteline_data.set_pixel(i%16, i/16, Color(position, note.column, theme.RADIAL_COL_ANGLES[note.column])) + noteline_data.set_pixel(i%16, i/16, Color(position, note.column, GameTheme.RADIAL_COL_ANGLES[note.column])) i += 1 - if position < theme.INNER_NOTE_CIRCLE_RATIO: - scale *= position/theme.INNER_NOTE_CIRCLE_RATIO - position = theme.INNER_NOTE_CIRCLE_RATIO - var note_center = (theme.RADIAL_UNIT_VECTORS[note.column] * position * theme.receptor_ring_radius) + if position < GameTheme.INNER_NOTE_CIRCLE_RATIO: + scale *= position/GameTheme.INNER_NOTE_CIRCLE_RATIO + position = GameTheme.INNER_NOTE_CIRCLE_RATIO + var note_center = (GameTheme.RADIAL_UNIT_VECTORS[note.column] * position * GameTheme.receptor_ring_radius) match note.type: Note.NOTE_TAP: - var color = theme.COLOR_ARRAY_DOUBLE_4 if note.double_hit else theme.COLOR_ARRAY_TAP + var color = GameTheme.COLOR_ARRAY_DOUBLE_4 if note.double_hit else GameTheme.COLOR_ARRAY_TAP make_tap_mesh(mesh, note_center, scale, color) Note.NOTE_HOLD: - var color = theme.COLOR_ARRAY_DOUBLE_8 if note.double_hit else theme.COLOR_ARRAY_HOLD - var position_rel : float = (t+theme.note_forecast_beats-note.time_release)/theme.note_forecast_beats + var color = GameTheme.COLOR_ARRAY_DOUBLE_8 if note.double_hit else GameTheme.COLOR_ARRAY_HOLD + var position_rel : float = (t+GameTheme.note_forecast_beats-note.time_release)/GameTheme.note_forecast_beats if position_rel > 0: - var note_rel_center := (theme.RADIAL_UNIT_VECTORS[note.column] * position_rel * theme.receptor_ring_radius) - noteline_data.set_pixel(j%16, 15, Color(position_rel, note.column, theme.RADIAL_COL_ANGLES[note.column])) + var note_rel_center := (GameTheme.RADIAL_UNIT_VECTORS[note.column] * position_rel * GameTheme.receptor_ring_radius) + noteline_data.set_pixel(j%16, 15, Color(position_rel, note.column, GameTheme.RADIAL_COL_ANGLES[note.column])) j += 1 - if position_rel < theme.INNER_NOTE_CIRCLE_RATIO: - position_rel = theme.INNER_NOTE_CIRCLE_RATIO - var note_center_rel = (theme.RADIAL_UNIT_VECTORS[note.column] * position_rel * theme.receptor_ring_radius) - make_hold_mesh(mesh, note_center, note_center_rel, scale, theme.RADIAL_COL_ANGLES[note.column], color) + if position_rel < GameTheme.INNER_NOTE_CIRCLE_RATIO: + position_rel = GameTheme.INNER_NOTE_CIRCLE_RATIO + var note_center_rel = (GameTheme.RADIAL_UNIT_VECTORS[note.column] * position_rel * GameTheme.receptor_ring_radius) + make_hold_mesh(mesh, note_center, note_center_rel, scale, GameTheme.RADIAL_COL_ANGLES[note.column], color) Note.NOTE_SLIDE: - var color = theme.COLOR_ARRAY_DOUBLE_4 if note.double_hit else theme.COLOR_ARRAY_STAR + var color = GameTheme.COLOR_ARRAY_DOUBLE_4 if note.double_hit else GameTheme.COLOR_ARRAY_STAR var angle = fmod(t/note.duration, 1.0)*TAU make_star_mesh(mesh, note_center, scale, angle, color) var trail_alpha := 1.0 - if position < theme.INNER_NOTE_CIRCLE_RATIO: + if position < GameTheme.INNER_NOTE_CIRCLE_RATIO: trail_alpha = 0.0 elif position < 1.0: - trail_alpha = min(1.0, (position-theme.INNER_NOTE_CIRCLE_RATIO)/(1-theme.INNER_NOTE_CIRCLE_RATIO*2)) + trail_alpha = min(1.0, (position-GameTheme.INNER_NOTE_CIRCLE_RATIO)/(1-GameTheme.INNER_NOTE_CIRCLE_RATIO*2)) else: - var trail_progress : float = clamp((t - note.time_hit - theme.SLIDE_DELAY)/(note.duration - theme.SLIDE_DELAY), 0.0, 1.0) + var trail_progress : float = clamp((t - note.time_hit - GameTheme.SLIDE_DELAY)/(note.duration - GameTheme.SLIDE_DELAY), 0.0, 1.0) var star_pos : Vector2 = note.get_position(trail_progress) var star_angle : float = note.get_angle(trail_progress) make_star_mesh(mesh, star_pos, 1.33, star_angle, color) @@ -238,6 +272,18 @@ func _draw(): $notelines.set_texture(noteline_data_tex) $meshinstance.set_mesh(mesh) + + var textmesh := ArrayMesh.new() + make_judgement_text(textmesh, TextWord.PERFECT+TextStyle.ARC, 0, 0.0) + make_judgement_text(textmesh, TextWord.GREAT+TextStyle.ARC_LATE, 1, 0.0) + make_judgement_text(textmesh, TextWord.GOOD+TextStyle.ARC_EARLY, 2, 0.1) + make_judgement_text(textmesh, TextWord.ALMOST+TextStyle.ARC_LATE, 3, 0.2) + make_judgement_text(textmesh, TextWord.MISS+TextStyle.ARC, 4, 0.4) + make_judgement_text(textmesh, TextWord.NICE+TextStyle.ARC, 5, 0.6) + make_judgement_text(textmesh, TextWord.OK+TextStyle.ARC, 6, 0.8) + make_judgement_text(textmesh, TextWord.NG+TextStyle.ARC, 7, 0.9) + $JudgeText.set_mesh(textmesh) + # draw_mesh(mesh, tex) var noteline_array_image := Image.new() @@ -251,13 +297,13 @@ func _ready(): all_notes = [] next_note_to_load = 0 - $meshinstance.material.set_shader_param("star_color", theme.COLOR_STAR) - $meshinstance.material.set_shader_param("held_color", theme.COLOR_HOLD_HELD) + $meshinstance.material.set_shader_param("star_color", GameTheme.COLOR_STAR) + $meshinstance.material.set_shader_param("held_color", GameTheme.COLOR_HOLD_HELD) $meshinstance.material.set_shader_param("bps", bpm/60.0) $meshinstance.material.set_shader_param("screen_size", get_viewport().get_size()) $meshinstance.set_texture(tex) - var rec_scale1 = (float(screen_height)/float(theme.receptor_ring_radius))*0.5 + var rec_scale1 = (float(screen_height)/float(GameTheme.receptor_ring_radius))*0.5 var uv_array_playfield := PoolVector2Array([Vector2(-1.0, -1.0)*rec_scale1, Vector2(-1.0, 1.0)*rec_scale1, Vector2(1.0, -1.0)*rec_scale1, Vector2(1.0, 1.0)*rec_scale1]) # var vertex_array_playfield := PoolVector2Array([ # Vector2(x_margin, screen_height), Vector2(x_margin, 0.0), @@ -332,7 +378,7 @@ func _process(delta): if next_note_to_load >= len(all_notes): # All notes have been loaded, maybe do something break - if all_notes[next_note_to_load].time_hit > (t + theme.note_forecast_beats): + if all_notes[next_note_to_load].time_hit > (t + GameTheme.note_forecast_beats): # Next chronological note isn't ready to load yet break # Next chronological note is ready to load, load it diff --git a/Receptors.gd b/Receptors.gd index 194a31d..5b1cf4a 100644 --- a/Receptors.gd +++ b/Receptors.gd @@ -8,11 +8,11 @@ var center := Vector2(0.0, 0.0) func _draw(): # Screen filter - draw_rect(Rect2(-screen_height/2, -screen_height/2, screen_height, screen_height), theme.screen_filter) + draw_rect(Rect2(-screen_height/2, -screen_height/2, screen_height, screen_height), GameTheme.screen_filter) # Receptor ring - var receptor_circle := arc_point_list(center, theme.receptor_ring_radius, 0.0, 360.0, 360) - var receptor_centers := arc_point_list(center, theme.receptor_ring_radius, Rules.FIRST_COLUMN_ANGLE_DEG, Rules.FIRST_COLUMN_ANGLE_DEG+360.0-Rules.COLS_ANGLE_DEG, Rules.COLS) + var receptor_circle := arc_point_list(center, GameTheme.receptor_ring_radius, 0.0, 360.0, 360) + var receptor_centers := arc_point_list(center, GameTheme.receptor_ring_radius, Rules.FIRST_COLUMN_ANGLE_DEG, Rules.FIRST_COLUMN_ANGLE_DEG+360.0-Rules.COLS_ANGLE_DEG, Rules.COLS) # Shadows for i in range(len(receptor_circle)-1): @@ -22,7 +22,7 @@ func _draw(): # Foregrounds for i in range(len(receptor_circle)-1): - draw_line(receptor_circle[i], receptor_circle[i+1], theme.receptor_color, ring_px, true) + draw_line(receptor_circle[i], receptor_circle[i+1], GameTheme.receptor_color, ring_px, true) for i in range(len(receptor_centers)): - draw_circle(receptor_centers[i], receptor_px/2, theme.receptor_color) + draw_circle(receptor_centers[i], receptor_px/2, GameTheme.receptor_color) diff --git a/main.tscn b/main.tscn index 37edf9f..f7c56b5 100644 --- a/main.tscn +++ b/main.tscn @@ -1,18 +1,19 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=14 format=2] [ext_resource path="res://main.gd" type="Script" id=1] [ext_resource path="res://songs/cirno_1080p_rt_cpu1_3M.webm" type="VideoStream" id=2] [ext_resource path="res://video.gd" type="Script" id=3] [ext_resource path="res://Receptors.gd" type="Script" id=4] [ext_resource path="res://NoteHandler.gd" type="Script" id=5] -[ext_resource path="res://shaders/notelines.shader" type="Shader" id=6] -[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=7] -[ext_resource path="res://Bezel.gd" type="Script" id=8] -[ext_resource path="res://assets/NotoSans.tres" type="DynamicFont" id=9] -[ext_resource path="res://InputHandler.gd" type="Script" id=10] +[ext_resource path="res://assets/text-4k.png" type="Texture" id=6] +[ext_resource path="res://shaders/notelines.shader" type="Shader" id=7] +[ext_resource path="res://shaders/notemesh.shader" type="Shader" id=8] +[ext_resource path="res://Bezel.gd" type="Script" id=9] +[ext_resource path="res://assets/NotoSans.tres" type="DynamicFont" id=10] +[ext_resource path="res://InputHandler.gd" type="Script" id=11] [sub_resource type="ShaderMaterial" id=1] -shader = ExtResource( 6 ) +shader = ExtResource( 7 ) shader_param/line_color = Plane( 0.8, 0.8, 1, 0.8 ) shader_param/line_color_double = Plane( 1, 1, 0.6, 0.9 ) shader_param/dot_color = Plane( 1, 1, 1, 0.8 ) @@ -24,7 +25,7 @@ shader_param/dot_fullbright_thickness = 0.013 shader_param/max_angle = 1.0708 [sub_resource type="ShaderMaterial" id=2] -shader = ExtResource( 7 ) +shader = ExtResource( 8 ) shader_param/bps = null shader_param/star_color = null shader_param/held_color = null @@ -34,7 +35,8 @@ shader_param/screen_size = null position = Vector2( 960, 540 ) script = ExtResource( 1 ) __meta__ = { -"_edit_vertical_guides_": [ 1450.0 ] +"_edit_horizontal_guides_": [ ], +"_edit_vertical_guides_": [ 420.85, 1500.91 ] } [node name="video" type="VideoPlayer" parent="."] @@ -61,6 +63,9 @@ script = ExtResource( 5 ) [node name="SlideTrailHandler" type="Node2D" parent="NoteHandler"] +[node name="JudgeText" type="MeshInstance2D" parent="NoteHandler"] +texture = ExtResource( 6 ) + [node name="notelines" type="MeshInstance2D" parent="NoteHandler"] material = SubResource( 1 ) @@ -68,13 +73,13 @@ material = SubResource( 1 ) material = SubResource( 2 ) [node name="Bezel" type="Node2D" parent="."] -script = ExtResource( 8 ) +script = ExtResource( 9 ) [node name="InputHandler" type="Label" parent="."] margin_left = -960.0 margin_top = -540.0 margin_right = 960.0 margin_bottom = 540.0 -custom_fonts/font = ExtResource( 9 ) +custom_fonts/font = ExtResource( 10 ) text = "Fingers on the screen:" -script = ExtResource( 10 ) +script = ExtResource( 11 ) diff --git a/project.godot b/project.godot index 8f7ab48..e85bdb5 100644 --- a/project.godot +++ b/project.godot @@ -30,7 +30,7 @@ channel_disable_time=5.0 Note="*res://Note.gd" FileLoader="*res://FileLoader.gd" Rules="*res://Rules.gd" -theme="*res://theme.gd" +GameTheme="*res://GameTheme.gd" [debug]