Skip to content

Instantly share code, notes, and snippets.

View EngineerSmith's full-sized avatar
🔧
🦆

Engineer Smith EngineerSmith

🔧
🦆
View GitHub Profile
@blixt
blixt / prng.js
Last active March 30, 2025 04:16
A very simple, seedable JavaScript PRNG. NOTE: Please read comments on why this is not a good choice.
// NOTICE 2020-04-18
// Please see the comments below about why this is not a great PRNG.
// Read summary by @bryc here:
// https://github.com/bryc/code/blob/master/jshash/PRNGs.md
// Have a look at js-arbit which uses Alea:
// https://github.com/blixt/js-arbit
/**
--[[
"semi-manual" garbage collection
specify a time budget and a memory ceiling per call.
called once per frame, this will spread any big collections
over a couple of frames, and "catch up" when there is. This
keeps GC burden much more predictable.
The memory ceiling provides some level of "relief valve" - if
@1bardesign
1bardesign / stable_sort.lua
Last active July 7, 2022 00:03
stable sorting routines for lua
-- stable sorting routines for lua
--
-- modifies the global table namespace so you don't have
-- to re-require it everywhere.
--
-- table.stable_sort
-- a fast stable sort
-- table.unstable_sort
-- alias for the builtin unstable table.sort
-- table.insertion_sort
@EngineerSmith
EngineerSmith / main.lua
Last active February 21, 2022 14:41
Pinch and zoom + pan in love2d
local lg, lt = love.graphics, love.touch
local insert, remove = table.insert, table.remove
local sqrt = math.sqrt
local x,y, w,h = love.window.getSafeArea()
local textW, textH = x+w,y+h
local a, b = textW/2, textH/2
local texture = lg.newCanvas(textW,textH)
lg.setCanvas(texture)
lg.setColor(.5,.5,.5)
@EngineerSmith
EngineerSmith / lua.reg
Created November 15, 2021 21:56
Add .lua to File Explorer context menu in windows 10
Windows Registry Editor Version 5.00
; new file type
[HKEY_CLASSES_ROOT\.lua]
@="lua"
; template
[HKEY_CLASSES_ROOT\.lua\ShellNew]
"FileName"=""
@1bardesign
1bardesign / pixelart-pointers.md
Created March 23, 2022 23:53
tips and references for folks getting started with pixel art, and a little bit of philosphy too

This is a work in progress 🛠️

Pixel art

Pixel art is like art, but with pixels.

Generally the distinction is made at the point where the placement and colour relationships of individual pixels have a significant impact on the final piece, and where the artist is (or should be) concerned about optimising those relationships. This generally means both lower overall resolutions and lower colour counts, but there are many important works of pixel art that transcend those restrictions.

Pixel art and game art are often intertwined. Pixel art has long been used for game art because earlier systems had lower resolutions and lower colour counts, making a pixel art approach more important. It is important to understand, however, that the modern pixel art "movement" occurred significantly after those limited systems were mainstream, the modern understanding of pixel art has been developed in a reasonably post-hoc manner and the amount of academic interest in the movement is relatively tiny, with most of the folks

local matrix4, vector2, vector3, vector4
matrix4 = {
__type = "matrix4",
__call = function(_, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, m16)
return setmetatable({
__type = "matrix4",
m01 = m1 or 0, m02 = m2 or 0, m03 = m3 or 0, m04 = m4 or 0,
m05 = m5 or 0, m06 = m6 or 0, m07 = m7 or 0, m08 = m8 or 0,
m09 = m9 or 0, m10 = m10 or 0, m11 = m11 or 0, m12 = m12 or 0,
@Sheepolution
Sheepolution / main.lua
Last active May 7, 2025 09:32
Basic Luasteam P2P example
local server = true -- Change to false for the client
local connectionId
local pollGroup
Steam = require "luasteam"
Steam.init()
-- We call this to let Steam know that we want to use the networking sockets API.
-- Which probably won't do much in this example, but it can save you a delay.