Skip to content

Instantly share code, notes, and snippets.

View lucasteles's full-sized avatar
:shipit:
Ship it!

Lucas Teles lucasteles

:shipit:
Ship it!
View GitHub Profile
@lucasteles
lucasteles / PlayerInput.cs
Last active October 2, 2025 17:13
C# Enum player input viewer
[Flags]
public enum PlayerInput : ushort
{
None = 0,
Up = 1 << 0,
Down = 1 << 1,
Left = 1 << 2,
Right = 1 << 3,
@lucasteles
lucasteles / Coroutines.cs
Last active August 28, 2025 17:50
Godot Coroutine (unity like)
global using Coroutine = System.Collections.Generic.IEnumerable<Coroutines.Wait>;
global using Wait = Coroutines.Wait;
using System;
// ReSharper disable AsyncVoidMethod
public static class Coroutines
{
public static async void Start(this Coroutine steps)
{
var mainLoopTree = Engine.GetMainLoop();
@lucasteles
lucasteles / Trail3D.cs
Created July 16, 2025 22:46
Godot C# custom 3D trail renderer
using System;
using Godot;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Based on
// https://gist.github.com/geegaz/8dfd61f600828c02acbbdaa749a2bbd5
// https://www.youtube.com/watch?v=vKrrxKS-lcA
@lucasteles
lucasteles / Granblue.gdshader
Created May 13, 2025 23:04
Godot ArcSys Style Shader
// author: @ijiru_masu
shader_type spatial;
uniform float specularThreshold : hint_range(0,1) = 0.5;
uniform float lightThreshold : hint_range(0,1) = 0.1;
uniform sampler2D BASE: source_color;
uniform sampler2D SSS: source_color;
uniform sampler2D ILM;
uniform sampler2D DETAIL: source_color;
@lucasteles
lucasteles / PopCount.cs
Created April 5, 2025 14:23
Calculate span pop count
static class Mem
{
public static int PopCount<T>(in T[] values) where T : unmanaged => PopCount<T>(values.AsSpan());
public static int PopCount<T>(in ReadOnlySpan<T> values) where T : unmanaged
{
#pragma warning disable S907
var count = 0;
var bytes = MemoryMarshal.AsBytes(values);
ref var current = ref MemoryMarshal.GetReference(bytes);
@lucasteles
lucasteles / FpsCounter.cs
Created April 3, 2025 02:22
FPS Counter
using System.Diagnostics;
public sealed class FpsCounter
{
double currentFps;
long lastFrameTime;
const float SmoothFactor = 0.1f;
public FpsCounter() => Reset();
@lucasteles
lucasteles / Easing.cs
Created January 29, 2025 15:16
C# Easing Functions
public static class Easing
{
#pragma warning disable S1121
public static float Linear(float k) => k;
public static class Quadratic
{
public static float In(float k) => k * k;
public static float Out(float k) => k * (2f - k);
@lucasteles
lucasteles / Fixed.cs
Created January 25, 2025 23:13
Fixed point number
public readonly struct Fixed :
IEquatable<Fixed>,
IComparable<Fixed>,
IFormattable, IUtf8SpanFormattable,
IComparisonOperators<Fixed, Fixed, bool>,
IAdditionOperators<Fixed, Fixed, Fixed>,
ISubtractionOperators<Fixed, Fixed, Fixed>,
IIncrementOperators<Fixed>,
IDecrementOperators<Fixed>
{
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
Check(Foo.A | Foo.B | Foo.C, Foo.B);
Check(Foo.A | Foo.B, Foo.C);
Check(Foo.A | Foo.C, Foo.None);
Check(Foo.A | Foo.B | Foo.C, Foo.B | Foo.C);
Check(Foo.A | Foo.B | Foo.D, Foo.B | Foo.C);
@lucasteles
lucasteles / Program.cs
Last active October 29, 2024 20:01
Multi API Request Samples
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Threading;
using System.Threading.Channels;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Diagnostics;