Last active
December 16, 2015 01:50
-
-
Save dermotbalson/3fa737c8d950b73839e7 to your computer and use it in GitHub Desktop.
Contest1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--# Start | |
function setup() | |
author="Starting code" | |
displayMode(NORMAL) | |
end | |
function draw() | |
background(0) | |
DrawName() | |
fill(255,255,0) | |
ellipse(WIDTH/2,HEIGHT/2,100) | |
end | |
--# yojimbo2000 | |
function setup() | |
author="yojimbo2000" | |
displayMode(OVERLAY) --give us some more room to play with | |
supportedOrientations(CurrentOrientation) --lock the orientation to whatever orientaion we're in | |
ball = physics.body(CIRCLE, 50) | |
walls = physics.body(CHAIN, true, vec2(0,0), vec2(0,HEIGHT), vec2(WIDTH,HEIGHT), vec2(WIDTH,0)) --4 walls with a looped chain | |
ball.position = vec2(WIDTH/2,HEIGHT/2) | |
ball.restitution = 0.4 --a little bit bouncy | |
ball.interpolate = true --smooth movement | |
end | |
function draw() | |
physics.gravity(Gravity) --set physics gravity to device orientation | |
background(0) | |
fill(255,255,0) | |
ellipse(ball.x, ball.y, ball.radius * 2) --draw ellipse at ball position | |
DrawName() | |
end | |
--# JhaSeh | |
function setup() | |
author="JhaSeh - drag your finger" | |
displayMode(NORMAL) | |
end | |
function draw() | |
background(0) | |
DrawName() | |
fill(255,255,0) | |
ellipse(CurrentTouch.x or 0,CurrentTouch.y or 0,size or 1) | |
end | |
function touched(touch) | |
if touch.state == BEGAN then | |
size=0 | |
elseif touch.state == MOVING then | |
size=size+1 | |
end | |
end | |
--# quezadav | |
function setup() | |
author="quezadav - touch the screen" | |
displayMode(NORMAL) | |
end | |
function draw() | |
background(0) | |
DrawName() | |
fill(255,255,0) | |
for i=1,10 do | |
ellipse(WIDTH/2,HEIGHT/2,CurrentTouch.x/i) | |
end | |
end | |
--# CodingIsLife | |
function setup() | |
author="CodingIsLife (with help from dave1707)" | |
displayMode(NORMAL) | |
parameter.integer("radius",1,240,1) | |
end | |
function draw() | |
background(0) | |
DrawName() | |
fill(255,255,0) | |
ellipse(WIDTH/2,HEIGHT/2,radius*2) | |
text(string.format("Area = %.2f\nPerimeter = %.2f",math.pi*radius^2,math.pi*2*radius),WIDTH/2,HEIGHT-100) | |
end | |
--# hpsoft | |
function setup() | |
author="hpsoft" | |
displayMode(NORMAL) | |
displayMode(OVERLAY) ; backingMode(RETAINED) ; background(0) | |
dim=2*math.random(15) ; vitesse=30+math.random(60) | |
end | |
function draw() | |
for i=0,math.random(vitesse) do | |
c1=math.random(255-vitesse+i) ; c2=math.random(255-vitesse+i) | |
c3=math.random(255-vitesse+i) ; fill(c1,c2,c3) | |
for j=0,math.random(vitesse) do | |
x=math.random(WIDTH/dim //1)*dim ; y=math.random(HEIGHT/dim //1)*dim | |
ellipse(x+i*dim,y+i*dim,dim) | |
end | |
end | |
DrawName() | |
end | |
--# TokOut | |
function setup() | |
author="TokOut" | |
displayMode(NORMAL) | |
x,s,d=nil,nil,nil | |
end | |
function draw() | |
if s==nil then s=0 elseif s<250 then s=s+1 end | |
if s==0 then f=1 elseif s==250 then f=-1 end | |
if x==nil then x=150 end | |
if x==150 then d=1 print("Ongoing.") elseif x==750 then d=-1 print("Backgoing.") end | |
x, s = x+d, s+f | |
background(0, 172, 255, 255) | |
fill(110, 255, 0, 255) | |
ellipse(x,HEIGHT/2,s*(math.pi-1)) | |
DrawName() | |
end | |
--# SolderKing | |
function setup() | |
author="SolderKing" | |
displayMode(NORMAL) | |
m,tab = mesh(), {} | |
for i=1,36 do | |
table.insert(tab, vec2(math.cos(math.rad(i*10))*50,math.sin(math.rad(i*10))*50)) | |
end | |
m.vertices = triangulate(tab) | |
m:setColors(255,255,0) | |
end | |
function draw() | |
background(0) | |
DrawName() | |
translate(WIDTH/2,HEIGHT/2) | |
m:draw() | |
num = math.random(36) | |
tab[num] = tab[num] * 0.95 | |
m.vertices = triangulate(tab) | |
end | |
function DrawName() | |
pushStyle() | |
font("AmericanTypewriter-Bold") | |
fontSize(30) | |
textMode(CORNER) | |
text(author,10,HEIGHT-40) | |
popStyle() | |
end | |
--# Jmv38 | |
function setup() | |
backingMode(RETAINED) | |
author="Jmv38" | |
displayMode(NORMAL) | |
end | |
function draw() | |
a = math.floor(ElapsedTime/3) | |
if a ~= k then background(0) end | |
k = a | |
fill(255,255,0) | |
for p= 1,10+k do | |
n = (n or 0) + 1 | |
x = (math.cos(n/100 * (10 + k)) * 0.4 + 0.5) * WIDTH | |
y = (math.sin(n/100 * 10) * 0.4 + 0.5) * HEIGHT | |
ellipse(x,y,5) | |
end | |
DrawName() | |
end | |
--# Main | |
-- MultiStep | |
function setup() | |
demos = listProjectTabs() | |
for i=#demos,1,-1 do | |
if demos[i]=="Notes" or demos[i]=="Utility" then table.remove(demos,i) end | |
end | |
table.remove(demos) --remove the last tab | |
startDemo() | |
global = "select a step" | |
end | |
function showList() | |
output.clear() | |
for i=1,#demos do print(i,demos[i]) end | |
end | |
function startDemo() | |
resetMatrix() | |
if cleanup then cleanup() end | |
setup,draw,touched,collide,PrintExplanation=nil,nil,nil,nil,nil | |
lastDemo=Demo or readProjectData("lastDemo") or 1 | |
lastDemo=math.min(lastDemo,#demos) | |
saveProjectData("lastDemo",lastDemo) | |
parameter.clear() | |
parameter.integer("Demo", 1, #demos, lastDemo,showList) | |
parameter.action("Run", startDemo) | |
loadstring(readProjectTab(demos[Demo]))() | |
if PrintExplanation then PrintExplanation() end | |
setup() | |
end | |
function DrawName() | |
pushStyle() | |
font("AmericanTypewriter-Bold") | |
fontSize(30) | |
textMode(CORNER) | |
text(author,10,HEIGHT-40) | |
popStyle() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment