Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: Xone on March 20, 2008

Title: particle helix thing
Post by: Xone on March 20, 2008

' - P-Helix V1.0 - Code by Xone (c)2k8


' User -------------------------------
P = 50 rem Particles
T = 15 rem Tail-L per Particle

ew = 40 rem Emitter Width [1 to 320]
es = 12 rem X Emit Speed

g = 1.3 rem Grav
a = 60 rem Air Fric

rem Axis Repel/Attract
Gx = 0.2
Gy = 1.3
' ------------------------------------



open window 640,512: X=320: Y=400: gosub st: Label Lp
setrgb 0,0,0,0:setdrawbuf CBu: CBu=1-CBu: setdispbuf CBu
clear window
for i = 1 to P
u(i)=u(i)-0.002:F=u(i)
v(i,1)=v(i,1)-v(i,1)/a:v(i,2)=v(i,2)-v(i,2)/a+g
t(i,1)=t(i,1)+v(i,1):t(i,2)=t(i,2)+v(i,2)
if t(i,1)<X v(i,1)=v(i,1)+(Gx*F)
if t(i,1)>X v(i,1)=v(i,1)-(Gx*F)
if t(i,2)<0 v(i,2)=v(i,2)+Gy*F
if t(i,2)>0 v(i,2)=v(i,2)-Gy*F
if t(i,2)>=Y+(F*2) then
v(i,1)=v(i,1)/1.01:v(i,2)=-v(i,2)/1.3:u(i)=u(i)-0.01
fi
if F<0.1 gosub sn: w(i)=w(i)+1: if w(i)>T w(i)=T
if w(i)<T then:f(i,w(i),1)=t(i,1):f(i,w(i),2)=t(i,2)
else
for L=1 to w(i)
if L<T then:f(i,L,1)=f(i,L+1,1):f(i,L,2)=f(i,L+1,2)
else:f(i,L,1)=t(i,1):f(i,L,2)=t(i,2):fi
next
fi
for S=1 to w(i): if u(i)>0.2 gosub fl:next
setrgb 1, 0,200*((F-0.3)*10),130*((F-0.3)*2):ss=(u(i)*1.2)
if F>0.4 fill rect t(i,1)-ss,t(i,2)-ss to t(i,1)+ss,t(i,2)+ss
next
Goto Lp
label st
for p = 1 to P
dim t(p,2):t(p,1)=X-ew+ran(ew*2):t(p,2)=Y
dim o(p,2):o(p,1)=t(p,1):o(p,2)=t(p,2)
dim v(p,2):v(p,1)=(-X+t(p,1))/(ew/es):v(p,2)=-p/6
dim u(p):u(p)=ran(1.1)
for j=1 to T
dim f(p,j,2):f(p,j,1)=t(p,1):f(p,j,2)=t(p,2)
dim w(p):w(p)=0
next
next
return
label fl
Q=(w(i)+1)-S:H=300-((S+S)*100)/T:K=u(i)*130:setrgb 1,K,H/1.4,0
if f(i,Q,1)<>o(i,1) and f(i,Q,2)<>o(i,2) then
if Q<w(i) line f(i,Q,1),f(i,Q,2)
if Q=w(i) line f(i,Q,1),f(i,Q,2) to f(i,Q,1),f(i,Q,2)
else
if Q<w(i) line f(i,Q+1,1),f(i,Q+1,2) to f(i,Q,1),f(i,Q,2)
line f(i,Q-1,1),f(i,Q-1,2) to f(i,Q-1,1),f(i,Q-1,2)
fi
return
label sn
u(i)=1.1: t(i,1)=X-ew+ran(ew*2):t(i,2)=Y
o(i,1)=t(i,1):o(i,2)=t(i,2)
v(i,1)=(-X+t(i,1))/(ew/es):v(i,2)=-i/6
for W=1 to T
f(i,W,1)=t(i,1):f(i,W,2)=t(i,2)
next
return


Hope this works ok. Sync to PC for best results using Jims PS2 Yabasic.

Just experimenting with stuff at the moment.
I've put some comments on the user variables if you wish to tweak   :)
Title: Re: particle helix thing
Post by: Rbz on March 20, 2008
yeah, nice particles effect, well done
Title: Re: particle helix thing
Post by: rain_storm on March 20, 2008
That looks sweet really nice Xone
Title: Re: particle helix thing
Post by: Xone on March 20, 2008
If it wasn't for jims emulator i couldn't have shared it. So I think it's
in the best place it can be here.
Title: Re: particle helix thing
Post by: Shockwave on March 21, 2008
Yeah :) Looks kind of like Neon Sperm :)

It looks really nice too, thanks for posting it Xone K+
Title: Re: particle helix thing
Post by: Xone on March 21, 2008
 :)
Title: Re: particle helix thing
Post by: Galileo on September 04, 2014
Oh, It's lovely.  :clap: