Skip to content

Instantly share code, notes, and snippets.

@harrisyu
harrisyu / joyboot.ahk
Created September 5, 2025 08:04
使用手柄启动 Godot 游戏场景
#Requires AutoHotkey v2.0
; Godot 运行当前场景
GodotRunCurrentScene() {
if WinExist("Godot Engine") {
WinActivate
Send "{F6}"
}
}
@harrisyu
harrisyu / palette_4x4.gdshader
Created June 18, 2025 08:58
Palette 4x4 Spatial Shader.
shader_type spatial;
render_mode cull_disabled;
uniform bool srgb = false;
uniform float back_face_darker : hint_range(0.0, 1.0, 0.01) = 0.1;
uniform vec4 color0 : source_color= vec4(0.93333333f, 0.90588235f, 0.87058824f, 1.0);
uniform vec4 color1 : source_color = vec4(0.8901960784313725, 0.6039215686274509, 0.6745098039215687, 1.0);
uniform vec4 color2 : source_color = vec4(0.7686274509803922, 0.36470588235294116, 0.6235294117647059, 1.0);
uniform vec4 color3 : source_color = vec4(0.38823529411764707, 0.29411764705882354, 0.49019607843137253, 1.0);
@harrisyu
harrisyu / AnimationTreeComposer.gd
Created June 9, 2025 03:55
Godot AnimationTree Extended class for creating animation tree by code in editor.
@tool
class_name AnimationTreeComposer extends AnimationTree
@export var model_container_path: NodePath
func use_model_in_container() -> void:
var model_container = get_node_or_null(model_container_path)
if model_container:
var m = model_container.get_node_or_null(model_container.model_path)
@harrisyu
harrisyu / GPLColorPalette.gd
Last active December 27, 2024 02:52
Extends Godot's ColorPalette resource to Load .gpl palette file
# Extends Godot's (version 4.4+) ColorPalette resource to Load .gpl palette file.
@tool
class_name GPLColorPalette extends ColorPalette
@export_global_file("*.gpl") var source_gpl: String
@export_tool_button("Load Palette From File", "PortableCompressedTexture2D") var convert_action = convert
func convert():
@harrisyu
harrisyu / cn_convert.gd
Last active November 3, 2023 02:29
Godot GDScript 简繁转换函数
extends Object
# 中文格式枚举
enum EnumChinese {
Simp,
Trad,
}
# 转为简体
@harrisyu
harrisyu / trail_3d.gd
Created September 13, 2022 15:46 — forked from axilirate/trail_3d.gd
A Custom 3D trail renderer for Godot 4.
class_name Trail3D extends MeshInstance3D
enum {VIEW, NORMAL, OBJECT}
enum {X, Y, Z}
@export var emit: bool = true
@export var distance: float= 0.1
@export_range(0, 99999) var segments: int = 20
@export var lifetime: float= 0.5
@export_range(0, 99999) var base_width: float = 0.5
@harrisyu
harrisyu / SMBDIS.ASM
Created September 20, 2020 06:17 — forked from 1wErt3r/SMBDIS.ASM
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@harrisyu
harrisyu / FireworkSprite.gd
Created August 17, 2020 12:14
将 Animated Sprite 用于特效的脚本,创建后自动播放,播放完成后销毁。
# 将 Animated Sprite 用于特效的脚本,创建后自动播放,播放完成后销毁。
extends AnimatedSprite
func _ready() -> void:
self.frame = 0
play()
yield(self,"animation_finished")
queue_free()
@harrisyu
harrisyu / PerformanceMonitor.gd
Created August 15, 2020 08:19
Godot - GDScript - Output performance info to label 将当前性能指标输出成文本
# PerformanceMonitor 将 Godot 当前性能指标输出成文本
extends Node
export(bool) var enabled := true
# 文本输出到的 label 控件
export(NodePath) var label_path
onready var label:Label = get_node(label_path)
const frame_time = 0.0167 # 基于 60 fps 的比值
var info :=""
@harrisyu
harrisyu / Uni2D.shader
Last active August 15, 2020 08:20
Godot - GLSL Shader - 2D Palette swap and tint / 2D 的调色版映射 + Tint
shader_type canvas_item;
uniform bool use_pallete;
uniform sampler2D pallete_texture;
uniform vec4 tint_color : hint_color = vec4(1.0);
uniform float tint_factor : hint_range(0, 1);
const float from_u = 0.25;
const float to_u = 0.75;
const float pal_size = 16f;