Instantly share code, notes, and snippets.

# Michael Ebensmebens

• Sort options
Created Sep 6, 2011
Complete code for my tutorial on mouse dragging in Love2D.
View main.lua
 function love.load() rect = { x = 100, y = 100, width = 100, height = 100, dragging = { active = false, diffX = 0, diffY = 0 } } end
Created Apr 23, 2011
Functions for quick left and right bitwise shifts in Lua.
View bit-shifts.lua
 function lshift(x, by) return x * 2 ^ by end function rshift(x, by) return math.floor(x / 2 ^ by) end
Created May 8, 2011
Example code for part 3 of my Cameras in Love2D tutorial series.
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)
Created Jan 13, 2019
Setting up an up-to-date LAMP stack server on Ubuntu 18.04
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
Created Jun 30, 2011
Vector class for my tutorial on Lua metatables.
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)
Created Nov 16, 2012
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 })
Created Oct 17, 2012
Generate sine wave tones in Love2D
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)
Created Dec 5, 2012
Simple glow/bloom GLSL shader for Love2D
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);
Created Dec 6, 2012
A post-processing effects manager for Love2D
View postfx.lua
 postfx = {} postfx.all = {} postfx.active = true local PixelEffect = class("PixelEffect") function PixelEffect:initialize(effect) self.effect = effect self.active = true end
Created Oct 22, 2012