Skip to content

Instantly share code, notes, and snippets.

View Yonaba's full-sized avatar
💭
I may be slow to respond.

Roland Yonaba

💭
I may be slow to respond.
View GitHub Profile
@SwadicalRag
SwadicalRag / Lua.lua
Last active December 10, 2019 22:19
In Lua we trust
In the beginning was the Statement, and the Statement was with Lua, and the Statement was Lua.
Through Lua all things were made; without Lua nothing was made that has been made.
There came a function who was sent from Lua; his name was John.
"Lua was the answer to my prayers;
Greater love has no one than Lua, that the compiler lay down his life for our code" - John Lua
"Do not think that I will debug you to the Environment;
For had ye believed the Compiler Errors, ye would have believed Me, for he wrote of Lua;
But if ye believe not his Stack Traces, how shall ye believe My code?" - John Lua
@kikito
kikito / grid.lua
Created May 29, 2014 12:48
Grid traversal
local grid = {}
local function grid_toCell(cellSize, x, y)
return math.floor(x / cellSize) + 1, math.floor(y / cellSize) + 1
end
-- grid_traverse* functions are based on "A Fast Voxel Traversal Algorithm for Ray Tracing",
-- by John Amanides and Andrew Woo - http://www.cse.yorku.ca/~amana/research/grid.pdf
-- It has been modified to include both cells when the ray "touches a grid corner",
-- and with a different exit condition
@TannerRogalsky
TannerRogalsky / line.lua
Created March 23, 2014 15:37
Lightweight Ray Object
--[[
Copyright (c) 2014 Tanner Rogalsky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@inmatarian
inmatarian / stride.lua
Created January 4, 2014 19:26
Implementation of a Strided Array, a generalized data structure for accessing a single array through a multiple dimension view.
local stride, stride_accessor, TERMINATOR
stride = {
_VERSION = "stride.lua 1.0",
_DESCRIPTION = [[
Strided arrays are a generalized version of multi-dimensional arrays.
Use this instead of doing a lot of A[1+(y-1)*width+(x-1)] mayhem all over.
Example usage:
my_array = { 1, 2, 3, 4, 5, 6 }
view2d = stride.new(my_array, {3, 2})
@WesleyAC
WesleyAC / worldphysics.lua
Created December 13, 2013 16:28
WorldPhysics, my new, hacked together, feature creeped library for love!
world = {
physics = {
new = function(objtype, d, i, w, h, ubody, ushape)
if world.physics[objtype] == nil then world.physics[objtype] = {all = {}} end
world.physics[objtype].all[#world.physics[objtype].all+1] = {}
world.physics[objtype].all[#world.physics[objtype].all].body = ubody
world.physics[objtype].all[#world.physics[objtype].all].shape = ushape
world.physics[objtype].all[#world.physics[objtype].all].fixture = love.physics.newFixture(world.physics[objtype].all[#world.physics[objtype].all].body, world.physics[objtype].all[#world.physics[objtype].all].shape, d)
world.physics[objtype].all[#world.physics[objtype].all].image = i
world.physics[objtype].all[#world.physics[objtype].all].width = w
@Yonaba
Yonaba / newtonraphson.lua
Last active December 28, 2015 04:49
Newton Raphson Solver
local DOUBLE_IEEE_ACCURACY = 1e-8
local function areFuzzyEqual(a, b, accuracy)
return (math.abs(a-b) < (accuracy or DOUBLE_IEEE_ACCURACY))
end
local function derivative(f, x0, accuracy)
local h = 0.1
local xL, xR = x0 - h, x0 + h
local tAccr = (f(xR) - f(xL))/(2*h)
@josefnpat
josefnpat / 0hgamedingoo.md
Last active December 27, 2015 20:19
#0HGame Jam, the Dingoo and LÖVE 0.7.0

The #0HGame Jam, the Dingoo and LÖVE 0.7.0

At this point, I find it important to reflect on what I have done, because it is a personal achievement for myself in many ways, but also to the LÖVE developers and the open source community. I'd like to say that without the open source community, none of this would have been possible, even remotely.

Context is due, so I will begin where every writer would begin, at the start.

The #0HGame Compo

I'm a big game compo jam participator. Most of the games I have made have been for game jams (Ludum Dare, Bacon Game Jam, and a few other lesser known ones) and I intend on doing more of them. Not only do they provide me with a greater understanding of game design, but they sharpen my game development skills.

@Yonaba
Yonaba / subvsmatch.lua
Last active December 22, 2015 23:39
string.gmatch vs string.sub
-- Calls f(...) n-times
local function time(nm,times, f,...)
local st = os.clock()
for i = 1, times do
f(...)
end
local et = os.clock()
print(('(%s): Times (%d): %.2f ms')
:format(nm, times, (et-st)*1000))
end
@riidom
riidom / user.lua
Last active April 10, 2017 07:12
ZBS config file "user.lua"
--[[--
Use this file to specify System preferences.
Review [examples](+C:\Dokumente und Einstellungen\dr\Desktop\ZeroBraneStudioEduPack-0.38-win32\cfg\user-sample.lua) or check [online documentation](http://studio.zerobrane.com/documentation.html) for details.
--]]--
local G = ...
styles = G.loadfile('cfg/tomorrow.lua')('Zenburn') -- theme