Snippets about gamedev
8 snippets
-
SNP142
Wait a second in GDScript
Pause a function without blocking the game, the Godot 4 way.
6 lines of gd in 3 blocks, 6 lines of explanation.
#5B3 -
SNP133
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.
3 lines of sh in 2 blocks, 9 lines of explanation with 4 notes.
#246 -
SNP132
Lerp and clamp
Two one-liners every game and animation ends up needing.
5 lines of js in 3 blocks, 8 lines of explanation.
#935 -
SNP129
Crisp pixel art on a canvas
The canvas smooths scaled sprites too. Turn it off, in two places.
9 lines of js and css in 2 blocks, 6 lines of explanation.
#513 -
SNP102
Seeded random numbers in JavaScript
Math.random() can't be seeded. For procedural levels you need one that can.
11 lines of js in 1 block, 5 lines of explanation.
#512 -
SNP088
Pick a random element in GDScript
Random loot, random lines, random enemies. Godot 4 has it built in.
6 lines of gd in 2 blocks, 5 lines of explanation.
#245 -
SNP055
Pixel-perfect settings in Godot 4
The project settings that keep pixel art sharp when the window is scaled.
9 lines of ini in 1 block, 13 lines of explanation with 5 notes.
#539 -
SNP042
Shuffle an array properly
The sort(() => Math.random() - 0.5) trick is biased. Fisher-Yates is just as short and actually random.
9 lines of js in 1 block, 5 lines of explanation.
#2B4