Skip to content

Instantly share code, notes, and snippets.

View hiulit's full-sized avatar
💻
Working

hiulit

💻
Working
View GitHub Profile
@Grunerd
Grunerd / LabelFontScaler.gd
Last active October 11, 2023 17:44
LabelFontScaler for Control Node in Godot 4
extends Control
# ensure that you attach this script to the parent node of your ui elements
# ensure that you link the signal "resize" of this control node to this script
#
@export_enum("Horizontal","Vertical") var scaleMode = "Vertical"
# cache for all labels and ther initial font size
@Gemba
Gemba / donutdodo_controller_mapping.py
Created June 30, 2023 10:50
Workaround to remap the Donut Dodo controller buttons to Retropie's Joypad definition.
#! /usr/bin/env python3
# Remaps the Donut Dodo Controller buttons to the values of Retropie's Joypad
# definition. cf. https://retropie.org.uk/forum/topic/34334/
# Usage:
#
# 1. Run Donut Dodo and in the "Remap Controller" Menu select Factory Reset
# once. This will create a
# /opt/retropie/configs/ports/donutdodo/controller_mapping.dat
@WolfgangSenff
WolfgangSenff / ShakeCamera2D.gd
Last active January 26, 2023 17:13
Camera shake from KidsCanCode
extends Camera2D
# Courtesy of KidsCanCode: http://kidscancode.org/godot_recipes/3.x/2d/screen_shake/ (this may change in the near future, so it may require a search)
# If you intend to use this, don't forget to turn on camera rotation! And keep in mind that smaller numbers are often the most useful - huge numbers make this thing *really* shake
# 3.5.x
export var decay = 0.8 # How quickly the shaking stops [0, 1].
export var max_offset = Vector2(100, 75) # Maximum hor/ver shake in pixels.
export var max_roll = 0.1 # Maximum rotation in radians (use sparingly).
export (NodePath) var target # Assign the node this camera will follow.
@fenix-hub
fenix-hub / #description.md
Last active May 9, 2024 19:08
GDScript JSON <> Class Serializer/Deserializer

You can find usages in the GDScript Unirest plugin

This is a fast serializer/deserializer written in GDScript to convert a JSON (Dictionary) to a class, using something similar to the Reflection concecpt. json_to_class can be used to convert a Dictionary to a Class. All keys in the Dictionary will be treated as variables and their types will be guessed in the best way possible. A class (defined by the class_name keyword) must extend Reference or Object or be an inner class, or else Godot will not able to see its properties. It is also possible to deserialize a JSON key to a class property with a different name using the export hint as a variable name.

example usage:

@Xrayez
Xrayez / gcd_lcm.lua
Last active April 16, 2023 12:53
Greatest Common Divisor (GCD) and Least Common Multiple (LCM) implemented in Lua
-- Greatest Common Divisor (Euclidean algorithm).
function math.gcd(a, b)
local t
while b ~= 0 do
t = b
b = math.fmod(a, b)
a = t
end
return a
end
@fenix-hub
fenix-hub / dateToUnixTimestamp.gd
Last active February 11, 2022 19:21
Converts an ISO 8601 Date String to UNIX Timestamp int
# The best option is always to confront dates based on their UNIX value
# With these scripts, you'll get something like "16778909182". Put it in the Array and sort it with the others.
var timestamp: String = "2021-08-04T16:45:35.603Z"
# Using String, Arrays and Dictionary
var datetime: PoolStringArray = timestamp.split("T")
var date: PoolStringArray = datetime[0].split("-")
var time: PoolStrngArray = datetime[1].split(":")
var unix_timestamp: int = OS.get_unix_time_from_datetime({year=date[0],month=date[1],day=date[2],hour=time[0],minute=time[1],second=time[2].substr(0,2)}
@WolfgangSenff
WolfgangSenff / gist:168cb0cbd486c8c9cd507f232165b976
Last active May 10, 2024 03:03
Godot 4.0 Migration/Upgrade guide
## For a beginner-friendly version of the following (more advanced users likely will get better use of the below,
## if you're just starting out...), see this new gist:
## https://gist.github.com/WolfgangSenff/0a9c1d800db42a9a9441b2d0288ed0fd
This document represents the beginning of an upgrade or migration document for GDScript 2.0 and Godot 4.0. I'm focusing on 2D
at the moment as I'm upgrading a 2D game, but will hopefully have more to add for 3D afterward.
## If you want more content like this, please help fund my cat's medical bills at https://ko-fi.com/kyleszklenski - thank you very much! On to the migration guide.
@AnidemDex
AnidemDex / flow_container.gd
Last active April 24, 2022 16:27
Node Container that wraps its childs nodes in its rect
tool
extends Container
#class_name FlowContainer
## Modified version of
## https://github.com/godotengine/godot/pull/56104 to be used in versions previous 3.5
## by AnidemDex
## Use it as you want
@Sephirothphoenix
Sephirothphoenix / Crystal.shader
Created February 25, 2021 05:58
Robe Shaders (Golden Scythe, Godot)
shader_type canvas_item;
void fragment() {
// Color of the current pixel
vec4 oC = texture(TEXTURE, UV);
// Get the difference between the current pixel color and the color to replace, and replace the color
// Exterior Main
if (max(max(max(abs(oC.r - 0.408), abs(oC.g - 0.282)), abs(oC.b - 0.471)), abs(oC.a - 1.0)) <= 0.01){oC = vec4(
@jordanlis
jordanlis / godot_2d_wind_shader.txt
Last active January 21, 2021 01:52
godot 2D wind shader
// original wind shader from https://github.com/Maujoe/godot-simple-wind-shader-2d/tree/master/assets/maujoe.simple_wind_shader_2d
// original script modified by HungryProton so that the assets are moving differently : https://pastebin.com/VL3AfV8D
//
// speed - The speed of the wind movement.
// minStrength - The minimal strength of the wind movement.
// maxStrength - The maximal strength of the wind movement.
// strengthScale - Scalefactor for the wind strength.
// interval - The time between minimal and maximal strength changes.
// detail - The detail (number of waves) of the wind movement.
// distortion - The strength of geometry distortion.