Snippets about gamedev
8 snippets
-
SNP 142
#5B3
Wait a second in GDScript
Pause a function without blocking the game, the Godot 4 way.
-
SNP 133
#246
Export a sprite sheet from Aseprite's command line
Put the export in a script so every save of the .aseprite file can rebuild the sheet.
-
SNP 132
#935
Lerp and clamp
Two one-liners every game and animation ends up needing.
-
SNP 129
#513
Crisp pixel art on a canvas
The canvas smooths scaled sprites too. Turn it off, in two places.
-
SNP 102
#512
Seeded random numbers in JavaScript
Math.random() can't be seeded. For procedural levels you need one that can.
-
SNP 088
#245
Pick a random element in GDScript
Random loot, random lines, random enemies. Godot 4 has it built in.
-
SNP 055
#539
Pixel-perfect settings in Godot 4
The project settings that keep pixel art sharp when the window is scaled.
-
SNP 042
#2B4
Shuffle an array properly
The sort(() => Math.random() - 0.5) trick is biased. Fisher-Yates is just as short and actually random.