Skip to content

Instantly share code, notes, and snippets.

@idbrii
idbrii / lospec_to_paint.py
Created March 8, 2024 07:18
Download and convert a lospec url to a Paint.NET palette.
#! /usr/bin/env python
"""
Download and convert a lospec url to a Paint.NET palette.
CC0
"""
import argparse
import tempfile
@idbrii
idbrii / kenney_renamer.bat
Created February 19, 2024 08:55
Give Kenney's free input prompt art meaningful names
:: Script to give meaningful names to tiles in these free CC0 art packs:
:: https://www.kenney.nl/assets/1-bit-input-prompts-pixel-16
:: https://www.kenney.nl/assets/input-prompts-pixel-16
pushd "C:\libraries\itch\kenney-game-assets\2D assets\Input Prompts Pixel 16×\Tiles"
mkdir light\xbox
mkdir light\playstation
mkdir light\nintendo
mkdir light\keyboard
@idbrii
idbrii / kinematic_car.gd
Created December 29, 2022 19:27
A 3d kinematic car for Godot 3.5
extends KinematicBody
class_name KinematicCar
# Based on MIT-licensed car tutorial from KidsCanCode
# https://kidscancode.org/godot_recipes/3.x/2d/car_steering/
# https://github.com/kidscancode/godot_recipes/blob/master/src-3/content/2D/car_steering.md
# Ported some features from https://kidscancode.org/godot_recipes/3.x/3d/kinematic_car/car_base/
export(float, -100, 0, 1) var gravity := -20.0
export(float, 0.001, 180, 1) var max_steering_angle := 15
@idbrii
idbrii / ffmpeg_helper.py
Created July 28, 2022 22:16
Easily resize videos with ffmpeg
#! /usr/bin/env python3
"""
Video editing tools.
I don't remember the args for ffmpeg and it's useful to run them on multiple
videos in sequence. Great for shrinking game video that was captured at 4k.
Assumes ffmpeg is in your path. On Win10, use scoop to install (https://scoop.sh/).
Use .cmd files like this to make a drag-and-drop target:
@idbrii
idbrii / pid.lua
Created June 9, 2022 17:45
A pid controller (proportional–integral–derivative controller) in lua
-- Public domain/CC0
-- A pid controller (proportional–integral–derivative controller).
-- Useful to track an entity without overshooting (like a docking spaceship).
-- Could be expanded to control orientation, speed, or other values.
-- Requires tuning values:
-- tuning = {
-- gain = {
-- -- all in [0,1]
@idbrii
idbrii / barebonesclass.lua
Last active August 28, 2022 19:46
The most basic class function I can imagine.
-- public domain, CC0
-- extremely basic class.
-- only supports instances and constructors (no inheritance, mixin, etc).
-- Copypaste this function to your module to avoid depending on a class library.
local function Class()
local cls = {}
cls.__index = cls
setmetatable(cls, {
__call = function(cls_, ...)
" An extremely rough approximation of vscode's inliner:
" https://www.youtube.com/watch?v=EenznqbW5w8
" Uses vim's popupwin to show the definition of a tag. Hijacks the arrow keys
" to let you move a cursor inside that window and jump to another tag.
"
" Public domain, CC0.
let g:tagpopper_z = 0
" Turning this off hides some bugs but then preview window is even more
" superior. Not sure why sometimes popup contents is clobbered.
@idbrii
idbrii / ShakeIn2D.cs
Last active February 2, 2024 15:13
Unity camera shake 2d
// Released under CC0 and Unlicense
// Demo: https://imgur.com/a/9h3c6W5
// Screenshake should move the camera around smoothly but unpredictably. It
// shouldn't jitter the camera around in a way that makes it hard to follow
// what's on screen. That's why you should use continuous oscillating functions
// to produce your shake instead of random values. I also think it's useful to
// make a directional shake to help connect the shaking to the thing that
// caused it.
@idbrii
idbrii / PrefabDetector.cs
Created October 17, 2020 13:30
A Unity editor window to show you the prefab-ness of an object
// public domain
// Add to Scripts/Editor/PrefabDetector.cs
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System;
using UnityEditor.Experimental.SceneManagement;
using UnityEditor.SceneManagement;
using UnityEditor;
using UnityEngine;
@idbrii
idbrii / main.lua
Last active July 19, 2020 01:06
Test file for chained function calls for lua syntax (from demo for flux.lua)
-- Test file for chained function calls for lua syntax
-- Source: https://love2d.org/forums/viewtopic.php?t=77904
local flux = require "flux"
local colon_out = self.kitchen
:getContents()
:getCheese()
:enjoyCheese(self
:mouth()