Added an interim title with shader effect.

This commit is contained in:
Henry 2025-12-28 13:38:13 +00:00
parent b5d97c0ffb
commit 6b3270bbb2
8 changed files with 155 additions and 1 deletions

View file

@ -60,10 +60,12 @@ func _on_player_died():
game_over.show()
await get_tree().create_timer(2).timeout
game_over.hide()
$CanvasLayer/Title.show()
start_button.show()
playing = false
func new_game():
$CanvasLayer/Title.hide()
# Ensure enemies are cleared.
get_tree().call_group("enemies", "queue_free")
get_tree().call_group("enemy_bullets", "queue_free")
@ -110,6 +112,7 @@ func win_game():
$Player._on_player_victory()
await get_tree().create_timer(2).timeout
game_over.hide()
$CanvasLayer/Title.show()
start_button.show()
func enemy_win() -> void:

View file

@ -1,8 +1,10 @@
[gd_scene load_steps=10 format=3 uid="uid://cc2dnhuv4qx7m"]
[gd_scene load_steps=13 format=3 uid="uid://cc2dnhuv4qx7m"]
[ext_resource type="Script" uid="uid://c51huloycn5as" path="res://main.gd" id="1_h2yge"]
[ext_resource type="Texture2D" uid="uid://jj8b7vqj3ihx" path="res://Mini Pixel Pack 3/Space_BG (2 frames) (64 x 64).png" id="1_ig7tw"]
[ext_resource type="PackedScene" uid="uid://s6wf3egdqtmh" path="res://ui.tscn" id="4_1bvp3"]
[ext_resource type="Texture2D" uid="uid://db2v7dea5wi4" path="res://title - no border.png" id="4_7mycd"]
[ext_resource type="Shader" uid="uid://x02irwg8ynvp" path="res://pixel_highlight.gdshader" id="4_272bh"]
[ext_resource type="Texture2D" uid="uid://bonoqs5pisflo" path="res://Mini Pixel Pack 3/UI objects/START (48 x 8).png" id="5_lquwl"]
[ext_resource type="Texture2D" uid="uid://bubqwoum50gf8" path="res://Mini Pixel Pack 3/UI objects/GAME_OVER (72 x 8).png" id="6_7mycd"]
@ -46,6 +48,15 @@ _data = {
&"scroll": SubResource("Animation_h2yge")
}
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kek77"]
shader = ExtResource("4_272bh")
shader_parameter/speed = 3.0000001425
shader_parameter/line_width = 0.1530000072675
shader_parameter/line_color = Color(1, 1, 1, 1)
shader_parameter/pause_duration = 5.314000252415
shader_parameter/offset = 2.0
shader_parameter/pixelate_line = 0
[node name="Main" type="Node2D"]
script = ExtResource("1_h2yge")
@ -70,6 +81,14 @@ autoplay = "scroll"
offset_right = 196.0
offset_bottom = 36.0
[node name="Title" type="TextureRect" parent="CanvasLayer"]
material = SubResource("ShaderMaterial_kek77")
offset_left = 28.0
offset_top = 74.0
offset_right = 212.0
offset_bottom = 141.0
texture = ExtResource("4_7mycd")
[node name="CenterContainer" type="CenterContainer" parent="CanvasLayer"]
anchors_preset = 15
anchor_right = 1.0

51
pixel_highlight.gdshader Normal file
View file

@ -0,0 +1,51 @@
shader_type canvas_item;
uniform float speed : hint_range(0.0, 5.0) = 1.0;
uniform float line_width : hint_range(0.0, 0.2) = 0.15;
uniform vec4 line_color : source_color = vec4(1.0, 1.0, 1.0, 1.0);
uniform float pause_duration : hint_range(0.0, 6.0) = 0.15;
uniform float offset = 2.0;
uniform int pixelate_line : hint_range(0, 1) = 1;
void fragment() {
vec4 base_texture = texture(TEXTURE, UV);
// Skip fully transparent pixels
if (base_texture.a < 0.01) {
discard;
}
// Cycle timing with pause at end
float cycle_duration = offset + pause_duration;
float adjusted_time = mod(TIME * speed, cycle_duration);
// Line movement with pause (right to left)
float line_position;
if (adjusted_time <= offset) {
line_position = offset - adjusted_time;
} else {
line_position = -0.3;
}
// Use UV directly for diagonal calculation
vec2 uv_for_line = UV;
// Pixelate the line position calculation (not the texture sampling)
if (pixelate_line == 1) {
vec2 texture_size = 1.0 / TEXTURE_PIXEL_SIZE;
uv_for_line = floor(UV * texture_size) / texture_size;
}
// Diagonal line rotation
vec2 rotated_uv = vec2(uv_for_line.x + uv_for_line.y, uv_for_line.y - uv_for_line.x) * 0.5;
float dist = abs(rotated_uv.x - line_position);
// Line width and smoothness
float line_intensity = smoothstep(line_width, 0.0, dist);
// Mix base texture with line color (respecting line_color alpha)
vec3 final_color = mix(base_texture.rgb, line_color.rgb, line_intensity * line_color.a);
// Preserve original alpha
COLOR = vec4(final_color, base_texture.a);
}

View file

@ -0,0 +1 @@
uid://x02irwg8ynvp

BIN
title - no border.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://db2v7dea5wi4"
path="res://.godot/imported/title - no border.png-f3a39f3e35d38034df2e041c7aa18607.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://title - no border.png"
dest_files=["res://.godot/imported/title - no border.png-f3a39f3e35d38034df2e041c7aa18607.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
title_white.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

40
title_white.png.import Normal file
View file

@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dfkr6mlotol6"
path="res://.godot/imported/title_white.png-d36b8f2d01d5f1557338a72c7191d974.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://title_white.png"
dest_files=["res://.godot/imported/title_white.png-d36b8f2d01d5f1557338a72c7191d974.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1