From bd02abaed0a906fa2b2565751252517c14f71c0f Mon Sep 17 00:00:00 2001 From: Harmony Honey Date: Fri, 5 Jan 2024 01:35:14 -0500 Subject: [PATCH] Level Select now loads instantly! All screens are laid out, then each map is loaded! Now using wide-screens (; TV Static is show during load. + cursor_anim.gd Obscure map, new wrecked tiles! To hint at a secret wall (-= Note will now fade in when out of bounds! no more tiles to hide/obscure it. Tiles now fade to half alpha ! Wipe duration decreased 0.0 --- media/image/solid_bricks.png | Bin 140 -> 183 bytes src/actor/Note.gd | 9 +- src/autoload/Shared.gd | 3 +- src/autoload/Wipe.gd | 7 +- src/autoload/Wipe.tscn | 1 + src/map/1-1.tscn | 2 +- src/map/1-2.tscn | 2 +- src/map/1-3.tscn | 2 +- src/map/1-4.tscn | 2 +- src/map/1-5.tscn | 2 +- src/map/1-6.tscn | 6 +- src/map/1-7.tscn | 2 +- src/map/1-8.tscn | 2 +- src/map/2-1.tscn | 2 +- src/map/2-2.tscn | 2 +- src/map/2-3.tscn | 2 +- src/map/2-4.tscn | 4 +- src/map/2-5.tscn | 2 +- src/map/2-6.tscn | 2 +- src/map/2-7.tscn | 2 +- src/map/2-8.tscn | 2 +- src/map/3-1.tscn | 2 +- src/map/3-2.tscn | 2 +- src/map/3-3.tscn | 2 +- src/map/3-4.tscn | 2 +- src/map/3-5.tscn | 2 +- src/map/3-6.tscn | 2 +- src/map/3-7.tscn | 2 +- src/map/3-8.tscn | 2 +- src/map/4-1.tscn | 2 +- src/map/4-2.tscn | 2 +- src/map/4-3.tscn | 2 +- src/map/4-4.tscn | 5 +- src/map/4-5.tscn | 2 +- src/map/4-7.tscn | 2 +- src/menu/cursor_anim.gd | 31 ++++++ src/menu/select.gd | 185 ++++++++++++++++++++++------------ src/menu/select.tscn | 164 +++++++++++++----------------- src/shader/tv_static.gdshader | 14 +++ src/stage/ObscureMap.gd | 16 ++- src/stage/ObscureMap.tscn | 6 +- 41 files changed, 300 insertions(+), 205 deletions(-) create mode 100644 src/menu/cursor_anim.gd create mode 100644 src/shader/tv_static.gdshader diff --git a/media/image/solid_bricks.png b/media/image/solid_bricks.png index fa77cde8ba716464daddceea6ead34e9bb92b79b..e680f33ec580c129eb0f4d77503baec4e63a2704 100644 GIT binary patch delta 142 zcmV;90CE3}0k;8=F@JGML_t(oh3(cc3cw%?1<;?~%0Um`4n0;o1xl$(OiGsjCLySi z1c~g&c>zGHMRdL5y}#8W0MI*A)wNu>I$dvrgHxJ#hTv>FfT0dEpS wM5)|ARBxW(JYY#8Rag%^aUQV7iHK6&PH0Z6BS9He00000Ne4wvM6N<$f@?-RHvj+t delta 98 zcmdna*uyx%Fxt)2#W5tJ_3b4?E(Qf2=Zn{(OE 0 - new.get_node("Overlay/Death").visible = is_death - if is_death: - new.get_node("Overlay/Death/Label").text = str(Shared.deaths[map_name]) - - screens.add_child(new) - overlays.append(new.get_node("Overlay")) - view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_path + Shared.maps[i] + ".tscn") - Leaderboard.connect("new_score", self, "new_score") SilentWolf.Scores.connect("sw_scores_received", self, "new_score") - scroll(Shared.current_map) - show_scoreboard() - load_list.sort_custom(self, "sort_load_list") + screen.rect_position -= Vector2.ONE * 500 + + map_limit = min(Shared.maps.size(), Shared.map_save) + + # make screens + screen_pos = [] + for i in map_limit: + var sy = i / columns + var sx = i % columns + screen_pos.append((Vector2(sx + (sy % 2) * 0.5, sy) * (screen_size + screen_dist))) + screen_list.append(i) + + scroll(Shared.current_map) + cam.reset_smoothing() + + screen_list.sort_custom(self, "sort_list") + is_screening = true + + show_scoreboard() func sort_load_list(a, b): if abs(a[0] - cursor) < abs(b[0] - cursor): return true return false +func sort_list(a, b): + if abs(a - cursor) < abs(b - cursor): + return true + return false + func _input(event): if !is_input: return @@ -88,6 +89,7 @@ func _input(event): open_map() Audio.play("menu_pick", 0.9, 1.1) is_input = false + is_load = false elif event.is_action_pressed("pause"): show_score = posmod(show_score + 1, 3) print("show_score: ", show_score) @@ -105,25 +107,73 @@ func _physics_process(delta): for i in last_refresh.keys(): last_refresh[i] = max(0, last_refresh[i] - delta) - # load stages - if loader == null and load_list.size() > 0: - loader = ResourceLoader.load_interactive(load_list[0][1]) - - if loader != null: + if is_screening: + screen_time += delta var ticks = OS.get_ticks_msec() - var tick_limit = delta * 77 - while OS.get_ticks_msec() < ticks + tick_limit: - var error = loader.poll() - if error == ERR_FILE_EOF: - var map = loader.get_resource().instance() - loader = null - load_list.pop_front()[2].add_child(map) - break - elif error != OK: - # failed - loader = null + while OS.get_ticks_msec() < ticks + (delta * timeout_mod): + if screen_list.size() > 0: + make_screen(screen_list.pop_front()) + else: + is_screening = false + is_load = true + print(screen_time, " screeening time") break + + # load stages + elif is_load: + loading_time += delta + if loader == null and load_list.size() > 0: + loader = ResourceLoader.load_interactive(load_list[0][1]) + + if loader != null: + var ticks = OS.get_ticks_msec() + + while OS.get_ticks_msec() < ticks + (delta * timeout_mod): + var error = loader.poll() + if error == ERR_FILE_EOF: + var map = loader.get_resource().instance() + var pop = load_list.pop_front() + pop[2].add_child(map) + screen_static[pop[0]].visible = false + loader = null + break + elif error != OK: + # failed + loader = null + break + + if load_list.size() == 0: + is_load = false + print(loading_time, " loading time") + +func make_screen(i := 0): + var new = screen.duplicate() + var map_name = Shared.maps[i] + + new.rect_position = screen_pos[i] + new.get_node("Overlay/Label").text = map_name + + var is_note := Shared.notes.has(map_name) + new.get_node("Overlay/Notes").visible = is_note + if is_note: + new.get_node("Overlay/Notes/Label").text = time_to_string(Shared.notes[map_name]) + + var is_time := Shared.map_times.has(map_name) + new.get_node("Overlay/Time").visible = is_time + if is_time: + new.get_node("Overlay/Time/Label").text = time_to_string(Shared.map_times[map_name]) + + var is_death : bool = Shared.deaths.has(map_name) and Shared.deaths[map_name] > 0 + new.get_node("Overlay/Death").visible = is_death + if is_death: + new.get_node("Overlay/Death/Label").text = str(Shared.deaths[map_name]) + + screens_node.add_child(new) + screens.append(new) + overlays.append(new.get_node("Overlay")) + screen_static.append(new.get_node("Vis/Static")) + view_scene(new.get_node("Vis/ViewportContainer/Viewport"), Shared.map_path + Shared.maps[i] + ".tscn") # view a scene inside the viewport by path func view_scene(port, path): @@ -134,15 +184,16 @@ func view_scene(port, path): port_count += 1 func scroll(arg = 0): - overlays[cursor].visible = true - cursor = clamp(cursor + arg, 0, screens.get_child_count() - 1) + if overlays.size() > cursor: + overlays[cursor].visible = true + cursor = clamp(cursor + arg, 0, map_limit - 1) current_map = Shared.maps[cursor] - overlays[cursor].visible = !score_node.visible - var screen_pos = screens.get_children()[cursor].rect_position - var pos = screen_pos + Vector2(50, 50) - cam.position = pos - score_node.rect_position = screen_pos + Vector2(1, 1) - cursor_node.position = pos + if overlays.size() > cursor: + overlays[cursor].visible = !score_node.visible + var sp = screen_pos[cursor] + cursor_node.rect_position = sp + score_node.rect_position = sp + Vector2(1, 1) + cam.position = sp + (screen_size * 0.5) refresh_score() func show_scoreboard(arg := show_score): @@ -154,13 +205,15 @@ func show_scoreboard(arg := show_score): Shared.is_replay = arg == 1 score_node.visible = show_score > 0 - overlays[cursor].visible = !score_node.visible + if overlays.size() > cursor: + overlays[cursor].visible = !score_node.visible refresh_score() func refresh_score(var map_name : String = current_map): if show_score == 0: return if show_score == 2: map_name += "-note" + score_map.text = current_map write_score() if !last_refresh.has(map_name) or last_refresh[map_name] == 0: @@ -186,7 +239,7 @@ func write_score(): count += 1 if count > 9 : break else: - t = "LOADING..." + t = "loading..." else: if Shared.replays.has(map_name): for i in Shared.replays[map_name]: diff --git a/src/menu/select.tscn b/src/menu/select.tscn index 5917104..d82ca47 100644 --- a/src/menu/select.tscn +++ b/src/menu/select.tscn @@ -1,13 +1,20 @@ -[gd_scene load_steps=14 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://media/image/corner.png" type="Texture" id=1] [ext_resource path="res://media/font/QuinqueFive.ttf" type="DynamicFontData" id=2] [ext_resource path="res://media/image/note.png" type="Texture" id=3] [ext_resource path="res://src/menu/Vis.gd" type="Script" id=4] +[ext_resource path="res://src/shader/tv_static.gdshader" type="Shader" id=5] [ext_resource path="res://src/shader/outline2D_outer.shader" type="Shader" id=6] [ext_resource path="res://src/menu/select.gd" type="Script" id=7] [ext_resource path="res://media/image/menu.png" type="Texture" id=10] [ext_resource path="res://media/image/skull.png" type="Texture" id=11] +[ext_resource path="res://src/menu/cursor_anim.gd" type="Script" id=13] + +[sub_resource type="ShaderMaterial" id=8] +shader = ExtResource( 5 ) +shader_param/mouse_pos = Vector2( 0.01, 0.005 ) +shader_param/vsync_issues = 0.7 [sub_resource type="DynamicFont" id=4] size = 5 @@ -40,63 +47,12 @@ extra_spacing_top = -1 extra_spacing_bottom = -1 font_data = ExtResource( 2 ) -[sub_resource type="Animation" id=1] -length = 1.15 -loop = true -tracks/0/type = "value" -tracks/0/path = NodePath("c1:position") -tracks/0/interp = 2 -tracks/0/loop_wrap = true -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/keys = { -"times": PoolRealArray( 0, 0.5, 1 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ Vector2( -55, -55 ), Vector2( -45, -45 ), Vector2( -55, -55 ) ] -} -tracks/1/type = "value" -tracks/1/path = NodePath("c2:position") -tracks/1/interp = 2 -tracks/1/loop_wrap = true -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/keys = { -"times": PoolRealArray( 0, 0.5, 1 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ Vector2( 55, -55 ), Vector2( 45, -45 ), Vector2( 55, -55 ) ] -} -tracks/2/type = "value" -tracks/2/path = NodePath("c3:position") -tracks/2/interp = 2 -tracks/2/loop_wrap = true -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/keys = { -"times": PoolRealArray( 0, 0.5, 1 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ Vector2( -55, 55 ), Vector2( -45, 45 ), Vector2( -55, 55 ) ] -} -tracks/3/type = "value" -tracks/3/path = NodePath("c4:position") -tracks/3/interp = 2 -tracks/3/loop_wrap = true -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/keys = { -"times": PoolRealArray( 0, 0.5, 1 ), -"transitions": PoolRealArray( 1, 1, 1 ), -"update": 0, -"values": [ Vector2( 55, 55 ), Vector2( 45, 45 ), Vector2( 55, 55 ) ] -} - -[node name="Node2D" type="Node2D"] +[node name="Select" type="Node2D"] script = ExtResource( 7 ) __meta__ = { "_edit_lock_": true } +screen_size = Vector2( 136, 96 ) [node name="Control" type="Control" parent="."] margin_right = 320.0 @@ -116,36 +72,40 @@ margin_right = 150.0 margin_bottom = 80.0 [node name="Vis" type="VisibilityNotifier2D" parent="Control/Screen"] -rect = Rect2( 0, 0, 100, 100 ) +rect = Rect2( 0, 0, 136, 96 ) script = ExtResource( 4 ) [node name="ViewportContainer" type="ViewportContainer" parent="Control/Screen/Vis"] -margin_left = -1.52588e-05 -margin_right = 100.0 -margin_bottom = 100.0 +margin_right = 136.0 +margin_bottom = 96.0 [node name="Viewport" type="Viewport" parent="Control/Screen/Vis/ViewportContainer"] -size = Vector2( 100, 100 ) -own_world = true +size = Vector2( 136, 96 ) handle_input_locally = false render_target_update_mode = 3 +[node name="Static" type="ColorRect" parent="Control/Screen/Vis"] +modulate = Color( 0.14, 0.14, 0.14, 1 ) +material = SubResource( 8 ) +margin_right = 136.0 +margin_bottom = 96.0 + [node name="Overlay" type="Control" parent="Control/Screen"] -margin_right = 100.0 -margin_bottom = 100.0 +margin_right = 136.0 +margin_bottom = 104.0 [node name="Label" type="Label" parent="Control/Screen/Overlay"] -margin_top = 47.0 -margin_right = 100.0 -margin_bottom = 52.0 +anchor_right = 1.0 +anchor_bottom = 1.0 grow_horizontal = 2 custom_fonts/font = SubResource( 4 ) text = "1-1" align = 1 +valign = 1 [node name="Time" type="Control" parent="Control/Screen/Overlay"] -margin_top = 100.0 -margin_bottom = 100.0 +margin_top = 96.0 +margin_bottom = 96.0 [node name="Clock" type="Sprite" parent="Control/Screen/Overlay/Time"] material = SubResource( 3 ) @@ -181,8 +141,8 @@ custom_fonts/font = SubResource( 4 ) text = "79" [node name="Notes" type="Control" parent="Control/Screen/Overlay"] -margin_left = 100.0 -margin_right = 100.0 +margin_left = 136.0 +margin_right = 136.0 [node name="Sprite" type="Sprite" parent="Control/Screen/Overlay/Notes"] material = SubResource( 3 ) @@ -200,32 +160,31 @@ text = "12:34" align = 2 [node name="Scores" type="Control" parent="Control"] -visible = false margin_left = 111.0 margin_top = 41.0 -margin_right = 209.0 -margin_bottom = 139.0 -rect_min_size = Vector2( 98, 98 ) +margin_right = 245.0 +margin_bottom = 135.0 +rect_min_size = Vector2( 134, 94 ) [node name="HBoxContainer" type="HBoxContainer" parent="Control/Scores"] anchor_right = 1.0 -margin_top = 3.0 -margin_bottom = 13.0 +margin_top = 1.0 +margin_bottom = 11.0 custom_constants/separation = 2 alignment = 1 [node name="Title" type="Label" parent="Control/Scores/HBoxContainer"] -margin_left = 2.0 +margin_left = 9.0 margin_top = 2.0 -margin_right = 85.0 +margin_right = 92.0 margin_bottom = 7.0 custom_fonts/font = SubResource( 6 ) text = "FASTEST note" valign = 1 [node name="Note" type="Control" parent="Control/Scores/HBoxContainer"] -margin_left = 87.0 -margin_right = 96.0 +margin_left = 94.0 +margin_right = 103.0 margin_bottom = 10.0 rect_min_size = Vector2( 9, 10 ) @@ -238,8 +197,8 @@ region_rect = Rect2( 7, 7, 9, 10 ) [node name="Clock" type="Control" parent="Control/Scores/HBoxContainer"] visible = false -margin_left = 92.0 -margin_right = 102.0 +margin_left = 110.0 +margin_right = 120.0 margin_bottom = 10.0 rect_min_size = Vector2( 10, 10 ) @@ -250,12 +209,22 @@ texture = ExtResource( 10 ) region_enabled = true region_rect = Rect2( 15, 7, 10, 10 ) +[node name="Map" type="Label" parent="Control/Scores/HBoxContainer"] +margin_left = 105.0 +margin_top = 2.0 +margin_right = 125.0 +margin_bottom = 7.0 +custom_fonts/font = SubResource( 6 ) +text = "1-3" +valign = 1 + [node name="List" type="Label" parent="Control/Scores"] -margin_top = 18.0 -margin_right = 98.0 -margin_bottom = 95.0 +margin_left = 1.0 +margin_top = 16.0 +margin_right = 133.0 +margin_bottom = 93.0 custom_fonts/font = SubResource( 5 ) -text = "1.67 / Me +text = "12:67 long_name1234567 1.94 / You 2.54 / Nobody 4. Everyone @@ -272,30 +241,33 @@ current = true smoothing_enabled = true editor_draw_screen = false -[node name="Cursor" type="Node2D" parent="."] +[node name="Cursor" type="Control" parent="."] modulate = Color( 1, 0.92549, 0.152941, 1 ) -position = Vector2( 160, 90 ) - -[node name="AnimationPlayer" type="AnimationPlayer" parent="Cursor"] -autoplay = "New Anim" -"anims/New Anim" = SubResource( 1 ) +margin_left = 110.0 +margin_top = 40.0 +margin_right = 246.0 +margin_bottom = 144.0 +script = ExtResource( 13 ) +time = 0.5 +distance = 9.0 +offset = -6.0 +size = Vector2( 136, 96 ) [node name="c1" type="Sprite" parent="Cursor"] -position = Vector2( -45, -45 ) texture = ExtResource( 1 ) [node name="c2" type="Sprite" parent="Cursor"] -position = Vector2( 45, -45 ) +position = Vector2( 136, 0 ) rotation = 1.5708 texture = ExtResource( 1 ) [node name="c3" type="Sprite" parent="Cursor"] -position = Vector2( -45, 45 ) -rotation = 4.71239 +position = Vector2( 0, 103 ) +rotation = -1.5708 texture = ExtResource( 1 ) [node name="c4" type="Sprite" parent="Cursor"] -position = Vector2( 45, 45 ) +position = Vector2( 136, 103 ) rotation = 3.14159 texture = ExtResource( 1 ) diff --git a/src/shader/tv_static.gdshader b/src/shader/tv_static.gdshader new file mode 100644 index 0000000..4884556 --- /dev/null +++ b/src/shader/tv_static.gdshader @@ -0,0 +1,14 @@ +shader_type canvas_item; + +uniform vec2 mouse_pos; +uniform float vsync_issues; + +float noise(float time, vec2 st) { + return fract(sin(dot(st.xy * vsync_issues, vec2(time, time * 13352.0) * mouse_pos)) * 8282.0); +} + +void fragment() { + vec2 st = UV.xy / (1.0 / SCREEN_PIXEL_SIZE.xy); + vec4 random = vec4(vec3(noise(TIME, st)), 1.0); + COLOR = random; +} \ No newline at end of file diff --git a/src/stage/ObscureMap.gd b/src/stage/ObscureMap.gd index 383d3db..4929e1c 100644 --- a/src/stage/ObscureMap.gd +++ b/src/stage/ObscureMap.gd @@ -1,9 +1,19 @@ extends TileMap +var frac = 0.0 +export var speed := 10.0 + func _ready(): - tile_set.tile_set_modulate(0, Color.black) - tile_set.tile_set_modulate(1, Color.transparent) + for i in 2: + tile_set.tile_set_modulate(i, Color.transparent) + + if Shared.is_level_select: return + + Shared.obscure_map = self func _physics_process(delta): + if Shared.is_level_select: return + if is_instance_valid(Shared.player): - modulate.a = lerp(modulate.a, 0.0 if get_cellv(world_to_map(Shared.player.center())) != -1 else 1.0, delta * 10.0) + frac = lerp(frac, 0.0 if get_cellv(world_to_map(Shared.player.center())) != -1 else 1.0, delta * speed) + modulate.a = lerp(0.5, 1.0, frac) diff --git a/src/stage/ObscureMap.tscn b/src/stage/ObscureMap.tscn index f533bed..10a0a8b 100644 --- a/src/stage/ObscureMap.tscn +++ b/src/stage/ObscureMap.tscn @@ -9,7 +9,7 @@ 0/name = "8pixel.png 0" 0/texture = ExtResource( 4 ) 0/tex_offset = Vector2( 0, 0 ) -0/modulate = Color( 0, 1, 0.06, 0.33 ) +0/modulate = Color( 0, 1, 0, 0.2 ) 0/region = Rect2( 0, 0, 8, 8 ) 0/tile_mode = 0 0/occluder_offset = Vector2( 0, 0 ) @@ -23,7 +23,7 @@ 1/name = "wipe.png 1" 1/texture = ExtResource( 6 ) 1/tex_offset = Vector2( 0, 0 ) -1/modulate = Color( 0, 1, 0, 0.2 ) +1/modulate = Color( 0, 1, 0, 0.627451 ) 1/region = Rect2( 32, 48, 8, 8 ) 1/tile_mode = 0 1/occluder_offset = Vector2( 0, 0 ) @@ -38,7 +38,7 @@ 2/texture = ExtResource( 3 ) 2/tex_offset = Vector2( 0, 0 ) 2/modulate = Color( 1, 1, 1, 1 ) -2/region = Rect2( 0, 0, 16, 8 ) +2/region = Rect2( 0, 0, 32, 8 ) 2/tile_mode = 2 2/autotile/icon_coordinate = Vector2( 0, 0 ) 2/autotile/tile_size = Vector2( 8, 8 )