Skip to content

Instantly share code, notes, and snippets.

@HoraceBury
HoraceBury / arrowlib.lua
Last active July 23, 2020 12:09
Arrow projectile with air drag applied to feathered tail.
-- arrow test
-- http://www.iforce2d.net/b2dtut/sticky-projectiles
-- video: http://screencast.com/t/vcPLSJR6xkIq
require("mathlib")
local sWidth, sHeight = display.actualContentWidth, display.actualContentHeight
local centerX, centerY = sWidth/2, sHeight/2
@HoraceBury
HoraceBury / dropboxapi.lua
Last active May 11, 2019 00:24
DropBox API v2 library.
-- DropBox API v2 Library
require("utils") -- https://gist.github.com/HoraceBury/9321964
local iolib = require("iolib") -- https://gist.github.com/HoraceBury/d8d2fa3382f82a7c7faa
iolib.isdebug = false
local lib = {}
local function printer(str)
iolib.isdebug = lib.IsDebug
@HoraceBury
HoraceBury / backswipelib.lua
Last active April 18, 2019 12:20
BackSwipe Navigation for Composer
-- swipe library
--[[ Libraries ]]--
local composer = require("composer")
--[[ Fields ]]--
local mainstage = display.getCurrentStage()
local stage = composer.stage
@HoraceBury
HoraceBury / cleanhtml.lua
Created February 14, 2014 13:37
Cleans rich text so that HTML is cleanly removed, p and br tags are reduced to new lines and some special characters are replaced with the text equivelents.
local t = [[ your html ]]
-- list of strings to replace (the order is important to avoid conflicts)
local cleaner = {
{ "&", "&" }, -- decode ampersands
{ "—", "-" }, -- em dash
{ "’", "'" }, -- right single quote
{ "“", "\"" }, -- left double quote
{ "”", "\"" }, -- right double quote
{ "–", "-" }, -- en dash
@HoraceBury
HoraceBury / posts
Created March 28, 2019 14:30
Links to useful posts in the Corona forums
Moving groups of physics objects
https://forums.coronalabs.com/topic/74929-moving-group-of-phyics-objects/
Setting a physics body's position
https://forums.coronalabs.com/topic/74900-how-to-permanently-set-bodys-x-position/
Collision events
https://forums.coronalabs.com/topic/74846-collision-events-order/
@HoraceBury
HoraceBury / debugconsole.lua
Last active January 29, 2019 13:38
Debug Print Console
-- debug console
local widget = require("widget")
local lib = {}
local originalPrintFunc = print
local debugPrintFunc = nil
local showingDebugConsole = false
@HoraceBury
HoraceBury / iolib.lua
Last active September 15, 2018 11:07
File IO supporting functions to make reading and writing files easier.
-- io operations
local json = require("json")
local lfs = require( "lfs" )
local iolib = {}
--[[ FACILITIES ]]--
local function toDate( timestamp )
@HoraceBury
HoraceBury / catmull.lua
Created August 2, 2018 09:54
Takes a table of x,y points and returns a smooth catmull-rom spline table of x,y points.
-- catmull-rom-spline library
-- Resources:
-- https://gist.github.com/1383576
-- http://codeplea.com/simple-interpolation
-- http://codeplea.com/introduction-to-splines
require("tablelib") -- https://gist.github.com/HoraceBury/9307117
require("mathlib") -- https://gist.github.com/HoraceBury/9431861
@HoraceBury
HoraceBury / _shadowlib.lua
Last active May 8, 2018 05:52
Shadow library. Given a display group, this will ensure that non-physics-based shadows will be updated to track their parent, whether the parent is physics-based or not. The test sample demonstrates using physics to provide a shadow, as well.
local lib = {}
function lib.newShadowLayer( shadowgroup )
local function refresh()
if (shadowgroup and shadowgroup.numChildren) then
for i=1, shadowgroup.numChildren do
local shadow = shadowgroup[i]
local object = shadowgroup[i].shadowparent
if (not shadow.isBodyActive) then
@HoraceBury
HoraceBury / Program.cs
Created April 4, 2018 12:54
Executing an equation in C# proven with nUnit.
using System;
using NUnit.Framework;
using System.Data;
namespace RandomTests
{
[TestFixture]
public class NumberTests
{
public static void Main(string[] args)