Skip to content

Instantly share code, notes, and snippets.

@mebens
mebens / camera.lua
Created May 8, 2011 20:52
Example code for part 3 of my Cameras in Love2D tutorial series.
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)
@mebens
mebens / api.lua
Created April 26, 2011 10:34
API suggestions for kikito. api.lua is the usage. implementation.lua is a possible implementation.
tween.update(dt)
tween(t, goal, callback, easing)
class('Foo', BaseClass, function(self) -- base class is optional
function instanceFunction(...)
-- ...
end
function self.classFunction(...)
-- ...
end
end)
@mebens
mebens / bit-shifts.lua
Created April 23, 2011 09:39
Functions for quick left and right bitwise shifts in Lua.
function lshift(x, by)
return x * 2 ^ by
end
function rshift(x, by)
return math.floor(x / 2 ^ by)
end
@mebens
mebens / color-output.rb
Created April 20, 2011 23:13
Simple module for colour output to the terminal.
module ColorOutput
RED = 31
GREEN = 32
YELLOW = 33
BLUE = 34
MAGENTA = 35
CYAN = 36
def self.wrap(s, start_code, end_code = nil)
end_code = start_code - (start_code % 10) + 9 if end_code.nil?
@mebens
mebens / gist:838371
Created February 22, 2011 08:27 — forked from schacon/gist:1
This is gist.
There are none like it, but this one is somebody's.
It is Bob's life.
I must master eggs as I must master my spam.
Without Tom gist is useless.
Without gist, splatted, fried cheese with sweet chilli sauce is useless.
@mebens
mebens / simple_ruby_server.rb
Created January 28, 2011 04:53
A very simple Ruby server setup.
require 'gserver'
class MyServer < GServer
def initialize(port=12345, *args)
super(port, *args)
end
def serve(io)
io.puts("The time is currently #{Time.now}")
end