Skip to content

Instantly share code, notes, and snippets.

@jmiskovic
jmiskovic / physarum.lua
Last active April 5, 2025 21:33
The LÖVR implementation of physarum model in a compute shader
-- https://cargocollective.com/sagejenson/physarum
-- also [Coding Adventure: Ant and Slime Simulations](https://www.youtube.com/watch?v=X-iSQQgOd1A)
-- "agents" move around and leave behind a trail
-- they also detect others' trail and steer towards it
local m = {}
local agent_count = 1e4
local iterations_per_frame = 3
@jmiskovic
jmiskovic / cycles.lua
Created April 19, 2025 20:27
Stabilize the LÖVR physics and state updates by running them at consistent intervals regardless of frame rate
-- require this file to have reduced input lag and game logic that runs consistently
-- inspired by https://gafferongames.com/post/fix_your_timestep/
-- note: this decouples update() from draw(); update() can run multiple times per frame
local m = {}
m.update_delta = 1 / 60
function lovr.run()
if lovr.timer then lovr.timer.step() end
@jmiskovic
jmiskovic / repl.lua
Created February 15, 2026 11:39
REPL debugger integrated into LÖVR error handler
local lovr = lovr
local dbg = require'debugger' -- https://codeberg.org/slembcke/debugger.lua - tested against 101cab55a4
dbg.auto_where = 4
dbg.use_color(true)
local DEFAULT_COLOR = {1, 1, 1}
local ANSI_COLORS = {
['0'] = {0.933, 0.867, 0.722},
['97'] = {0.933, 0.867, 0.722},