Created
November 9, 2011 20:05
-
-
Save iTarum/1352794 to your computer and use it in GitHub Desktop.
Particelexapmles
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
posx=nil | |
dx={} | |
dy={} | |
posx={} | |
posy={} | |
anz=504 | |
dk=500 | |
size=10 | |
x=0 | |
y=100 | |
tgr=30 | |
st=.01 | |
emp=10 | |
z=1 | |
sf=10 | |
fa=1 | |
function setup() | |
iparameter("size",1,50) | |
iparameter("dk",0,200) | |
iparameter("anz",1,400,1) | |
parameter("st",0,2,1) | |
iparameter("emp",1,400,1) | |
iparameter("sf",1,100,1) | |
iparameter("fa",1,5,1) | |
watch("GravityX") | |
watch("GravityY") | |
for q=1,anz do | |
dx[q]=0 | |
dy[q]=0 | |
x=x+tgr | |
if x>WIDTH then | |
x=tgr | |
y = y + tgr | |
end | |
posx[q]=x | |
posy[q]=y | |
end | |
end | |
function draw() | |
GravityX = Gravity.x -- a bit not nice | |
GravityY = Gravity.y | |
noSmooth() | |
fill(0, 0, 0, dk) | |
rect(0,0,WIDTH,HEIGHT) | |
noStroke() | |
if CurrentTouch.state == BEGAN or CurrentTouch.state == MOVING then | |
for w=1,anz do | |
if fa==1 or fa==4 then | |
dx[w] = (( CurrentTouch.x-posx[w])/emp) + (math.sin(w) * sf) | |
dy[w] = ((CurrentTouch.y- posy[w])/emp) + (math.cos(w) * sf) | |
end | |
if fa==2 or fa==3 then | |
dx[w] = (( CurrentTouch.x-posx[w])/emp) + (math.sin(w) *sf) | |
dy[w] = ((CurrentTouch.y- posy[w])/emp) + (math.cos(w) *sf) | |
end | |
end | |
end | |
z = z + 1 | |
if z> anz then | |
z=1 | |
end | |
for q=1,anz do | |
if fa==4 then | |
dx[q] = dx[q] + Gravity.x | |
dy[q] = dy[q] + Gravity.y | |
end | |
dy[q] = dy[q] -(dy[q]*st) | |
dx[q] = dx[q] -(dx[q]*st) | |
posx[q] = posx[q] + dx[q] | |
if posx[q]<=0 or posx[q]>= WIDTH then | |
dx[q]=-dx[q] | |
posx[q] = posx[q] + dx[q] | |
end | |
posy[q] = posy[q] + dy[q] | |
if posy[q] <=0 or posy[q]>=HEIGHT then | |
dy[q]=-dy[q] | |
posy[q] = posy[q] + dy[q] | |
end | |
fill(212, 234, 17, 255) | |
rect(posx[q], posy[q], size,size) | |
if fa==3 and q<anz then | |
line( posx[q],posy[q],posx[q+1],posy[q+1]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment