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 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) |
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
extern float factor = 1; | |
extern float addPercent = 0.1; | |
extern float clamp = 0.85; | |
// from http://www.ozone3d.net/blogs/lab/20110427/glsl-random-generator/ | |
float rand(vec2 n) | |
{ | |
return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233))) * 43758.5453); | |
} |
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
#!/usr/bin/env lua | |
function exit(msg, code) | |
print(msg) | |
os.exit(code or 1) | |
end | |
function main() | |
if #arg < 4 then exit("Please provide a magnitude and angle for two polar vectors") end | |
local m1, a1, m2, a2 = unpack(arg) |
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
Tilemap = class("Tilemap") | |
Tilemap._mt = {} | |
function Tilemap._mt:__index(key) | |
return rawget(self, "_" .. key) or self.class.__instanceDict[key] | |
end | |
Tilemap:enableAccessors() | |
function Tilemap:initialize(img, fw, fh, width, height) |
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
Sheet = class("Sheet") | |
function Sheet:initialize(img, tileWidth, tileHeight) | |
self.x = 0 | |
self.y = 0 | |
self.image = img | |
self.tw = tileWidth | |
self.th = tileHeight | |
self.quads = {} | |
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
Spritemap = class("Spritemap") | |
Spritemap._mt = {} | |
function Spritemap._mt:__index(key) | |
return rawget(self, "_" .. key) or self.class.__instanceDict[key] | |
end | |
Spritemap:enableAccessors() | |
function Spritemap:initialize(img, fw, fh, complete, ...) |
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
-- returns nil if there's no movement | |
function getDirection() | |
local xAxis = input.axisDown("left", "right") | |
local yAxis = input.axisDown("up", "down") | |
local xAngle = xAxis == 1 and 0 or (xAxis == -1 and math.tau / 2 or nil) | |
local yAngle = yAxis == 1 and math.tau / 4 or (yAxis == -1 and math.tau * 0.75 or nil) | |
if xAngle and yAngle then | |
-- x = 1, y = -1 is a special case the doesn't fit; not sure what I can do about it other than this: | |
if xAxis == 1 and yAxis == -1 then return yAngle + math.tau / 8 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
-- converted from http://www.seventhstring.com/resources/notefrequencies.html | |
notes = { | |
[0] = { ["c"] = 16.35, ["c#"] = 17.32, ["d"] = 18.35, ["d#"] = 19.45, ["e"] = 20.60, ["f"] = 21.83, ["f#"] = 23.12, ["g"] = 24.50, ["g#"] = 25.96, ["a"] = 27.50, ["a#"] = 29.14, ["b"] = 30.87, }, | |
[1] = { ["c"] = 32.70, ["c#"] = 34.65, ["d"] = 36.71, ["d#"] = 38.89, ["e"] = 41.20, ["f"] = 43.65, ["f#"] = 46.25, ["g"] = 49.00, ["g#"] = 51.91, ["a"] = 55.00, ["a#"] = 58.27, ["b"] = 61.74, }, | |
[2] = { ["c"] = 65.41, ["c#"] = 69.30, ["d"] = 73.42, ["d#"] = 77.78, ["e"] = 82.41, ["f"] = 87.31, ["f#"] = 92.50, ["g"] = 98.00, ["g#"] = 103.8, ["a"] = 110.0, ["a#"] = 116.5, ["b"] = 123.5, }, | |
[3] = { ["c"] = 130.8, ["c#"] = 138.6, ["d"] = 146.8, ["d#"] = 155.6, ["e"] = 164.8, ["f"] = 174.6, ["f#"] = 185.0, ["g"] = 196.0, ["g#"] = 207.7, ["a"] = 220.0, ["a#"] = 233.1, ["b"] = 246.9, }, | |
[4] = { ["c"] = 261.6, ["c#"] = 277.2, ["d"] = 293.7, ["d#"] = 311.1, ["e"] = 329.6, ["f"] = 349.2, ["f#"] = 370.0, ["g"] = 392.0, ["g#"] = 41 |
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
Also installing dependencies: libsgml | |
==> Downloading http://www.hick.org/code/skape/libsgml/libsgml-1.1.4.tar.gz | |
######################################################################## 100.0% | |
==> Downloading patches | |
######################################################################## 100.0% | |
######################################################################## 100.0% | |
######################################################################## 100.0% | |
######################################################################## 100.0% | |
######################################################################## 100.0% | |
==> Patching |
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
// These are some nice reusable mixins I keep around | |
@mixin transition($type, $time, $ease) { | |
-webkit-transition: $type $time $ease; | |
transition: $type $time $ease; | |
} | |
@mixin border-radius($length) { | |
border-radius: $length; | |
-webkit-border-radius: $length; |