Skip to content

Instantly share code, notes, and snippets.

love.graphics.setDefaultFilter("linear", "linear", 16)
function love.load()
love.window.setMode(800, 600, { msaa = 0 })
end
local triCanvas = love.graphics.newCanvas(2*1792, 2*828, { msaa = 8 })
local function mkCanvas()
triCanvas:clear()
end
@incinirate
incinirate / ZipContainer.hpp
Last active March 23, 2019 05:30
Zip Container/Iterator for C++
#ifndef ZIPCONTAINER_H
#define ZIPCONTAINER_H
#include <utility>
template<typename V1, typename V2>
class ZipContainer {
private:
V1 &cRef1;
@incinirate
incinirate / Trie.hs
Last active December 3, 2018 00:31
Trie Implementation
extract :: (a -> Bool) -> [a] -> (Maybe a, [a])
extract _ [] = (Nothing, [])
extract pred (x:xs)
| pred x = (Just x, xs)
| otherwise = (x:) <$> extract pred xs
data Trie a = Node { datum :: Maybe a
, children :: [Trie a] }
@incinirate
incinirate / target.lua
Last active November 16, 2018 18:29
Missile targeting algorithm via numeric approximation
local sqrt = math.sqrt
local cos, sin = math.cos, math.sin
local targetStep = 0.1 -- Determines targeting accuracy, lower is better (but slower)
local function targetAngle(missile, target)
local px = missile.pos.x
local py = missile.pos.y
local vx = missile.vel.x
local vy = missile.vel.y
local am = missile.accel
@incinirate
incinirate / 0_x86emu.lua
Last active October 30, 2018 18:09
Simple x86 (GAS/AT&T flavor asm) emulator for Riko4
local cursor = require("ui.cursor").new()
local running = true
local env = {
rax = 0,
rbx = 0,
rcx = 0,
rdx = 0,
rsi = 0,
rdi = 0,
@incinirate
incinirate / float.lua
Last active November 5, 2018 05:21
Floating Point visualization for Riko4 (rlua)
local exp = 5
local frac = 3
local args = {...}
if args[1] then exp = tonumber(args[1]) end
if args[2] then frac = tonumber(args[2]) end
local bits = {0}
for i = 1, exp do
@incinirate
incinirate / test.c
Last active December 23, 2018 21:46
Demonstration of slowdown when using BlitRect
#include "SDL.h"
#include "SDL_gpu.h"
#include <stdio.h>
#define WIDTH 280
#define HEIGHT 160
#define SCALE 3
bool running = true;
bool doScale = true;
@incinirate
incinirate / xenon-build.lua
Last active May 13, 2018 23:38
Don't read me, I'm a squashed and bundled nightmare
-- vim: syntax=lua
-- luacheck: globals loadRemote getRemote fs loadstring peripheral
-- Load required libs / files
local surface = (function()
local surface = { } do
--[[
Surface 2
@incinirate
incinirate / complex.lua
Created October 13, 2017 04:10
Complex number library for Lua, supports all basic operations
local complex = {}
do
function complex.init(a, b)
local c = {real = a, imag = b}
setmetatable(c, {__index = complex,
__add = complex.add,
__sub = complex.sub,
__mul = complex.mul,
__div = complex.div,
__pow = complex.pow,
@incinirate
incinirate / 0_pproc.lua
Last active November 7, 2018 06:57
"Find and Replace" macro preprocessor for Lua
--[[
USAGE: pproc <inputFile> [outputFile]
If outputFile is not specified, pproc will write output to this path: inputFile .. ".lua"
]]
local args = { ... }