Skip to content

Instantly share code, notes, and snippets.

function deepcopy(orig)
local orig_type = type(orig)
local copy
if orig_type == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
@dermotbalson
dermotbalson / 18. Board game
Created April 9, 2013 14:43
18. Board game
--# Main
-- Flood
function setup()
if backup then backup("Flood 101") end
parameter.integer("Size",10,30,15) --size of board
parameter.action("Start",Start) --starts a new game
parameter.integer("Moves_so_far",0,100,0)
parameter.action("Undo",UndoMove)
--set up palette of six colors
supportedOrientations(LANDSCAPE_ANY)
-- Use this function to perform your initial setup
function setup()
parameter.number("noiseScale", 1/30, 1, 1/5)
parameter.number("noiseSpeed", 0.05, 1, 0.2)
parameter.integer("Red",0,255,0) --these parameters added
parameter.integer("Blue",0,255,255)
parameter.integer("Green",0,255,150)
parameter.integer("Alpha",0,255,0)
--# Main
-- Main
function setup()
parameter.integer("Game",1,2,1)
games={Game1,Game2}
end
function SetupGame()
if g then g:cleanup() end
g=games[Game]
@dermotbalson
dermotbalson / 22. Raytracing
Last active December 16, 2015 00:18
22. Raytracing
--# Main
-- Main
function setup()
t=Track1()
end
function draw()
t:draw()
end
@dermotbalson
dermotbalson / 23. Raytracing
Created April 9, 2013 14:48
23. Raytracing
--# Main
-- Main
function setup()
t=Track2()
parameter.boolean("Rays",true)
end
function draw()
t:draw()
@dermotbalson
dermotbalson / 24. Raytracing
Created April 9, 2013 14:49
24. Raytracing
--# Main
-- Main
function setup()
if Backup then Backup("TrackDemo 200") end
t=Track3()
parameter.boolean("Rays",true)
end
function draw()
function setup()
--use the emoji viewer software to get the number of the icon you want
--(when viewing a page of icons, press on the one you want, and note the number
emoji=unicode2UTF8(128120)
end
function draw()
background(0)
font("AppleColorEmoji")
fontSize(128)
--# Main
-- Main
function setup()
parameter.integer("Size",10,100,25)
parameter.action("Create",createMaze)
parameter.action("Solve",SolveMaze)
offset={x=50,y=50} --offset of maze from bottom left corner
end
@dermotbalson
dermotbalson / 30
Created April 10, 2013 06:36
30. Text input
--# Main
-- Main
function setup()
setupParameters()
end
--this function shows how to include/exclude parameters that show on the left of screen
function setupParameters(showTextClose)