-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added multiple target buttons, added clear dot action
- Loading branch information
enrico
committed
Feb 13, 2022
1 parent
b83a026
commit 6258417
Showing
12 changed files
with
120 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,8 @@ | ||
[gd_scene load_steps=4 format=2] | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://src/Main.gd" type="Script" id=1] | ||
|
||
[sub_resource type="Shader" id=1] | ||
code = "shader_type canvas_item; | ||
|
||
const float PI = 3.14159265359; | ||
|
||
uniform vec2 screen_size = vec2(320.0, 180.0); | ||
uniform bool show_curvature = true; | ||
uniform float curvature_x_amount : hint_range(3.0, 15.0, 0.01) = float(6.0); | ||
uniform float curvature_y_amount : hint_range(3.0, 15.0, 0.01) = float(4.0); | ||
uniform vec4 corner_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0); | ||
uniform bool show_vignette = true; | ||
uniform float vignette_opacity : hint_range(0.0, 1.0, 0.01) = 0.2; | ||
uniform bool show_horizontal_scan_lines = true; | ||
uniform float horizontal_scan_lines_amount : hint_range(0.0, 180.0, 0.1) = 180.0; | ||
uniform float horizontal_scan_lines_opacity : hint_range(0.0, 1.0, 0.01) = 1.0; | ||
uniform bool show_vertical_scan_lines = false; | ||
uniform float vertical_scan_lines_amount : hint_range(0.0, 320.0, 0.1) = 320.0; | ||
uniform float vertical_scan_lines_opacity : hint_range(0.0, 1.0, 0.01) = 1.0; | ||
uniform float boost : hint_range(1.0, 2.0, 0.01) = 1.2; | ||
uniform float aberration_amount : hint_range(0.0, 10.0, 0.01) = 0.0; | ||
|
||
vec2 uv_curve(vec2 uv) { | ||
if (show_curvature) { | ||
uv = uv * 2.0 - 1.0; | ||
vec2 offset = abs(uv.yx) / vec2(curvature_x_amount, curvature_y_amount); | ||
uv = uv + uv * offset * offset; | ||
uv = uv * 0.5 + 0.5; | ||
} | ||
|
||
return uv; | ||
} | ||
|
||
|
||
void fragment() { | ||
vec2 uv = uv_curve(UV); | ||
vec2 screen_uv = uv_curve(SCREEN_UV); | ||
vec3 color = texture(SCREEN_TEXTURE, screen_uv).rgb; | ||
|
||
if (aberration_amount > 0.0) { | ||
float adjusted_amount = aberration_amount / screen_size.x; | ||
color.r = texture(SCREEN_TEXTURE, vec2(screen_uv.x + adjusted_amount, screen_uv.y)).r; | ||
color.g = texture(SCREEN_TEXTURE, screen_uv).g; | ||
color.b = texture(SCREEN_TEXTURE, vec2(screen_uv.x - adjusted_amount, screen_uv.y)).b; | ||
} | ||
|
||
if (show_vignette) { | ||
float vignette = uv.x * uv.y * (1.0 - uv.x) * (1.0 - uv.y); | ||
vignette = clamp(pow((screen_size.x / 4.0) * vignette, vignette_opacity), 0.0, 1.0); | ||
color *= vignette; | ||
} | ||
|
||
if (show_horizontal_scan_lines) { | ||
float s = sin(screen_uv.y * horizontal_scan_lines_amount * PI * 2.0); | ||
s = (s * 0.5 + 0.5) * 0.9 + 0.1; | ||
vec4 scan_line = vec4(vec3(pow(s, horizontal_scan_lines_opacity)), 1.0); | ||
color *= scan_line.rgb; | ||
} | ||
|
||
if (show_vertical_scan_lines) { | ||
float s = sin(screen_uv.x * vertical_scan_lines_amount * PI * 2.0); | ||
s = (s * 0.5 + 0.5) * 0.9 + 0.1; | ||
vec4 scan_line = vec4(vec3(pow(s, vertical_scan_lines_opacity)), 1.0); | ||
color *= scan_line.rgb; | ||
} | ||
|
||
if (show_horizontal_scan_lines || show_vertical_scan_lines) { | ||
color *= boost; | ||
} | ||
|
||
// Fill the blank space of the corners, left by the curvature, with black. | ||
if (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0) { | ||
color = corner_color.rgb; | ||
} | ||
|
||
COLOR = vec4(color, 1.0); | ||
}" | ||
|
||
[sub_resource type="ShaderMaterial" id=2] | ||
render_priority = 3 | ||
shader = SubResource( 1 ) | ||
shader_param/screen_size = Vector2( 320, 180 ) | ||
shader_param/show_curvature = true | ||
shader_param/curvature_x_amount = 4.65 | ||
shader_param/curvature_y_amount = 3.35 | ||
shader_param/corner_color = Color( 0, 0, 0, 1 ) | ||
shader_param/show_vignette = true | ||
shader_param/vignette_opacity = 0.3 | ||
shader_param/show_horizontal_scan_lines = true | ||
shader_param/horizontal_scan_lines_amount = 0.0 | ||
shader_param/horizontal_scan_lines_opacity = 0.4 | ||
shader_param/show_vertical_scan_lines = false | ||
shader_param/vertical_scan_lines_amount = 260.5 | ||
shader_param/vertical_scan_lines_opacity = 0.31 | ||
shader_param/boost = 1.1 | ||
shader_param/aberration_amount = 0.0 | ||
|
||
[node name="Main" type="Node2D"] | ||
script = ExtResource( 1 ) | ||
|
||
[node name="CurrentScene" type="Node2D" parent="."] | ||
|
||
[node name="CanvasLayer" type="CanvasLayer" parent="."] | ||
layer = 10 | ||
|
||
[node name="CRTShader" type="ColorRect" parent="CanvasLayer"] | ||
visible = false | ||
material = SubResource( 2 ) | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
margin_right = -0.00012207 | ||
mouse_filter = 2 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://src/ui/AllyTargetButton.tscn" type="PackedScene" id=1] | ||
[ext_resource path="res://src/ui/MultiTargetButton.gd" type="Script" id=2] | ||
|
||
[node name="AllyMultiTargetButton" type="Node2D"] | ||
script = ExtResource( 2 ) | ||
target_button_reference = ExtResource( 1 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[gd_scene load_steps=3 format=2] | ||
|
||
[ext_resource path="res://src/ui/MultiTargetButton.gd" type="Script" id=1] | ||
[ext_resource path="res://src/ui/EnemyTargetButton.tscn" type="PackedScene" id=2] | ||
|
||
[node name="EnemyMultiTargetButton" type="Node2D"] | ||
script = ExtResource( 1 ) | ||
target_button_reference = ExtResource( 2 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
extends Node2D | ||
|
||
export (PackedScene) var target_button_reference = load("res://src/ui/EnemyTargetButton.tscn") | ||
|
||
signal pressed() | ||
|
||
func _ready(): | ||
pass # Replace with function body. | ||
|
||
# targets is a Array of Vector2 | ||
func init(targets): | ||
for target in targets: | ||
var new_target_button = target_button_reference.instance() | ||
new_target_button.global_position = target | ||
new_target_button.connect("pressed", self, "press") | ||
new_target_button.connect("mouse_entered", self, "mouse_entered") | ||
new_target_button.connect("mouse_exited", self, "mouse_exited") | ||
add_child(new_target_button) | ||
|
||
func press(): | ||
emit_signal("pressed") | ||
|
||
func mouse_entered(): | ||
for child in get_children(): | ||
child.set_hover_sprite(true) | ||
func mouse_exited(): | ||
for child in get_children(): | ||
child.set_hover_sprite(false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters