View camera.lua
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) |
View main.lua
function love.load() | |
rect = { | |
x = 100, | |
y = 100, | |
width = 100, | |
height = 100, | |
dragging = { active = false, diffX = 0, diffY = 0 } | |
} | |
end |
View bit-shifts.lua
function lshift(x, by) | |
return x * 2 ^ by | |
end | |
function rshift(x, by) | |
return math.floor(x / 2 ^ by) | |
end |
View guide.sh
# 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 |
View Vector.lua
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) |
View example.lua
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 }) |
View gist:3904043
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) |
View gist:4218802
// 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); |
View postfx.lua
postfx = {} | |
postfx.all = {} | |
postfx.active = true | |
local PixelEffect = class("PixelEffect") | |
function PixelEffect:initialize(effect) | |
self.effect = effect | |
self.active = true | |
end |
View gist:3929259
local function scale(x, min1, max1, min2, max2) | |
return min2 + ((x - min1) / (max1 - min1)) * (max2 - min2) | |
end | |
local function distance(x1, y1, x2, y2) | |
return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2) | |
end | |
function radialGradient(radius) | |
local data = love.image.newImageData(radius * 2, radius * 2) |
NewerOlder