This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function lshift(x, by) | |
return x * 2 ^ by | |
end | |
function rshift(x, by) | |
return math.floor(x / 2 ^ by) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// adapted from http://www.youtube.com/watch?v=qNM0k522R7o | |
extern vec2 size; | |
extern int samples = 5; // pixels per axis; higher = bigger glow, worse performance | |
extern float quality = 2.5; // lower = smaller glow, better quality | |
vec4 effect(vec4 colour, Image tex, vec2 tc, vec2 sc) | |
{ | |
vec4 source = Texel(tex, tc); | |
vec4 sum = vec4(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function table.reverse(t) | |
local len = #t + 1 | |
for i = 1, math.floor(#t / 2) do | |
t[i], t[len - i] = t[len - i], t[i] | |
end | |
return t | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vector = {} | |
Vector.__index = Vector | |
function Vector.__add(a, b) | |
if type(a) == "number" then | |
return Vector.new(b.x + a, b.y + a) | |
elseif type(b) == "number" then | |
return Vector.new(a.x + b, a.y + b) | |
else | |
return Vector.new(a.x + b.x, a.y + b.y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function love.load() | |
rect = { | |
x = 100, | |
y = 100, | |
width = 100, | |
height = 100, | |
dragging = { active = false, diffX = 0, diffY = 0 } | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
camera = {} | |
camera._x = 0 | |
camera._y = 0 | |
camera.scaleX = 1 | |
camera.scaleY = 1 | |
camera.rotation = 0 | |
function camera:set() | |
love.graphics.push() | |
love.graphics.rotate(-self.rotation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require("list") | |
local a = { 3 } | |
local b = { 4 } | |
local l = list({ 2 }, a, b, { 5 }) | |
l:pop() | |
l:shift() | |
l:push({ 6 }) | |
l:unshift({ 7 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script correlating to tutorial at http://ebens.me/post/install-lamp-stack-ubuntu | |
# Even though you probably could, don't run it all at once | |
# new user | |
adduser new_user | |
usermod -a -G sudo new_user | |
su - new_user | |
# new repos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local samples = 100000 | |
local data = love.sound.newSoundData(samples) | |
local noteChange = 10000 | |
local note = 200 | |
local change = 50 | |
local minimum = 100 | |
for i = 0, samples * 2 - 1 do | |
if i % noteChange == 0 then | |
local factor = -2 + math.random(0, 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postfx = {} | |
postfx.all = {} | |
postfx.active = true | |
local PixelEffect = class("PixelEffect") | |
function PixelEffect:initialize(effect) | |
self.effect = effect | |
self.active = true | |
end |
NewerOlder