forked from team-sg/hero-mark-2
first commit
This commit is contained in:
commit
096ebe5aa4
275 changed files with 3937 additions and 0 deletions
28
scripts/1px_border.gdshader
Normal file
28
scripts/1px_border.gdshader
Normal file
|
@ -0,0 +1,28 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform vec4 border_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
uniform bool border_corners = false;
|
||||
|
||||
bool is_border(sampler2D tex, vec2 uv, vec2 pixel_size) {
|
||||
float check = texture(tex, uv + vec2(pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(0.0, pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(0.0, -pixel_size.y)).a;
|
||||
|
||||
if (border_corners) {
|
||||
check += texture(tex, uv + pixel_size).a;
|
||||
check += texture(tex, uv - pixel_size).a;
|
||||
check += texture(tex, uv + vec2(pixel_size.x, -pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, pixel_size.y)).a;
|
||||
}
|
||||
|
||||
return check > 0.0;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
COLOR = texture(TEXTURE, UV);
|
||||
|
||||
if (COLOR.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
|
||||
COLOR = border_color;
|
||||
}
|
||||
}
|
4
scripts/delete_on_game_running.gd
Normal file
4
scripts/delete_on_game_running.gd
Normal file
|
@ -0,0 +1,4 @@
|
|||
extends Node
|
||||
|
||||
func _ready():
|
||||
queue_free()
|
14
scripts/recolor.tres
Normal file
14
scripts/recolor.tres
Normal file
|
@ -0,0 +1,14 @@
|
|||
[gd_resource type="Shader" format=2]
|
||||
|
||||
[resource]
|
||||
code = "// Recolor
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D palette : hint_albedo;
|
||||
|
||||
void fragment() {
|
||||
vec4 color = texture(TEXTURE, UV);
|
||||
vec4 result_color = texture(palette, color.rg );
|
||||
result_color.a = color.a;
|
||||
COLOR = result_color;
|
||||
}"
|
32
scripts/recolor_border.shader
Normal file
32
scripts/recolor_border.shader
Normal file
|
@ -0,0 +1,32 @@
|
|||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D palette : hint_albedo;
|
||||
uniform vec4 border_color : hint_color = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
uniform bool border_corners = false;
|
||||
|
||||
bool is_border(sampler2D tex, vec2 uv, vec2 pixel_size) {
|
||||
float check = texture(tex, uv + vec2(pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, 0.0)).a;
|
||||
check += texture(tex, uv + vec2(0.0, pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(0.0, -pixel_size.y)).a;
|
||||
|
||||
if (border_corners) {
|
||||
check += texture(tex, uv + pixel_size).a;
|
||||
check += texture(tex, uv - pixel_size).a;
|
||||
check += texture(tex, uv + vec2(pixel_size.x, -pixel_size.y)).a;
|
||||
check += texture(tex, uv + vec2(-pixel_size.x, pixel_size.y)).a;
|
||||
}
|
||||
|
||||
return check > 0.0;
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
vec4 color = texture(TEXTURE, UV);
|
||||
|
||||
if (color.a == 0.0 && is_border(TEXTURE, UV, TEXTURE_PIXEL_SIZE)) {
|
||||
COLOR = border_color;
|
||||
} else {
|
||||
COLOR = texture(palette, color.rg );
|
||||
COLOR.a = color.a;
|
||||
}
|
||||
}
|
43
scripts/scaling.gd
Normal file
43
scripts/scaling.gd
Normal file
|
@ -0,0 +1,43 @@
|
|||
extends Control
|
||||
|
||||
var multiple = 1
|
||||
onready var viewport = $ViewportContainer
|
||||
onready var border = $TextureRect
|
||||
# SCALE MODE: INTEGER, FIT, FILL
|
||||
export var scale_mode = 0
|
||||
# INTEGER SCALE SETTINGS
|
||||
export var overscale = 0
|
||||
onready var root = get_tree().root
|
||||
# RESOLUTION
|
||||
onready var res = Game.resolution
|
||||
onready var half_res = Vector2(res.x/2,res.y/2)
|
||||
|
||||
func _ready():
|
||||
#SCREEN RESIZE SIGNAL
|
||||
get_tree().connect("screen_resized", self, "_on_screen_resized")
|
||||
root.set_attach_to_screen_rect(root.get_visible_rect())
|
||||
_on_screen_resized()
|
||||
|
||||
func _on_screen_resized():
|
||||
# VARS
|
||||
var window_size = OS.get_window_size()
|
||||
# INTEGER SCALE
|
||||
if scale_mode == 0:
|
||||
# CENTER THE VIEWPORT
|
||||
viewport.rect_position.x = (window_size.x / 2) - half_res.x
|
||||
viewport.rect_position.y = (window_size.y / 2) - half_res.y
|
||||
# DETERMINE WHAT THE HIGHEST INTEGER MULTIPLE IS
|
||||
multiple = window_size / res
|
||||
multiple = Vector2(floor(multiple.x),floor(multiple.y))
|
||||
# SET THE HIGHEST SCALE AXIS TO THE LOWEST TO STAY SQUARE
|
||||
if multiple.x < multiple.y: multiple.y = multiple.x
|
||||
if multiple.x > multiple.y: multiple.x = multiple.y
|
||||
# SCALE THE VIEWPORT (IF OVERSCALE IS ON, SCALE IT BY 1 EXTRA)
|
||||
viewport.rect_scale = multiple + Vector2(overscale,overscale)
|
||||
#viewport.rect_scale = Vector2(2,2)
|
||||
# SCALE TO FIT
|
||||
if scale_mode == 1:
|
||||
get_tree().set_screen_stretch(SceneTree.STRETCH_MODE_VIEWPORT,SceneTree.STRETCH_ASPECT_KEEP,res,1)
|
||||
# BORDER
|
||||
border.rect_size = window_size
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue