Skip to content

Instantly share code, notes, and snippets.

View zorggn's full-sized avatar

zorg zorggn

  • Hungary
View GitHub Profile
@zorggn
zorggn / desktopmousecoords.lua
Last active June 1, 2016 14:40
Desktop mouse coordinates with Löve
-- desktop coordinate related functions
-- by zorg @ 2015-2016
-- license: ISC
-- This library implements a somewhat robust method of allowing the usage of desktop mouse coordinates in Löve.
-- Main usage would be the implementation of borderless dragging (in windows at least, where it's not possible otherwise)
-- This may not yet be perfect, since window dimensions and position and the inner canvas/frame/viewport dimensions and positioning
-- may be offset differently by different OS-es, so testing needed still. Also doesn't have that much use on android or ios.
@zorggn
zorggn / main.lua
Created January 23, 2016 22:29
Simple circular fading shader, uses screen_coords instead of texture_coords.
local w,h
local quad
local time, value
local mask_shader
function love.load()
w,h = love.graphics.getDimensions()
time = 0.0
value = math.sin(time)
quad = love.graphics.newQuad(0,0,w,h,w,h)
@zorggn
zorggn / main.lua
Last active December 8, 2015 19:42
Lua hax #84721365: Calling plain tostring in custom tostring metamethod to get table address.
local t = {}
local toString = function(t)
local original = getmetatable(t)
local modified = {}; for k,v in pairs(original) do modified[k] = v end; modified.__tostring = nil
setmetatable(t, modified)
local address = tostring(t):sub(8)
setmetatable(t, original)
return string.format("Identifying table:\n%s\nYep, it's a table.", address)
end