Snippets about gamedev

8 snippets

Back to all snippets

  1. SNP 142 #5B3

    Wait a second in GDScript

    Pause a function without blocking the game, the Godot 4 way.

  2. 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.

  3. SNP 132 #935

    Lerp and clamp

    Two one-liners every game and animation ends up needing.

  4. SNP 129 #513

    Crisp pixel art on a canvas

    The canvas smooths scaled sprites too. Turn it off, in two places.

  5. SNP 102 #512

    Seeded random numbers in JavaScript

    Math.random() can't be seeded. For procedural levels you need one that can.

  6. SNP 088 #245

    Pick a random element in GDScript

    Random loot, random lines, random enemies. Godot 4 has it built in.

  7. SNP 055 #539

    Pixel-perfect settings in Godot 4

    The project settings that keep pixel art sharp when the window is scaled.

  8. 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.