'Coded by Ashish in Qb64
'inspire from Shiffman's video.
Particles
(i
).
pos.z
= RND * 100 Particles(i).i = 5
IF RND * 2 > 1 THEN Particles
(i
).i
= -Particles
(i
).i
Particles
(i
).rr
= RND * 3 CASE 0: Particles
(i
).r
= 5: Particles
(i
).g
= 205: Particles
(i
).b
= 229 CASE 1: Particles
(i
).r
= 255: Particles
(i
).g
= 184: Particles
(i
).b
= 3 CASE 2: Particles
(i
).r
= 91: Particles
(i
).g
= 3: Particles
(i
).b
= 255 CASE 3: Particles
(i
).r
= 61: Particles
(i
).g
= 62: Particles
(i
).b
= 62 CASE 4: Particles
(i
).r
= 255: Particles
(i
).g
= 0: Particles
(i
).b
= 255 CASE 5: Particles
(i
).r
= 255: Particles
(i
).g
= 0: Particles
(i
).b
= 0 CASE 6: Particles
(i
).r
= 0: Particles
(i
).g
= 255: Particles
(i
).b
= 0 CASE 7: Particles
(i
).r
= 0: Particles
(i
).g
= 0: Particles
(i
).b
= 255 IF RND * 2 > 1 THEN Particles
(i
).j
= -Particles
(i
).j
glAllow = -1
CIRCLE (Particles
(i
).
pos.x
, Particles
(i
).
pos.y
), Particles
(i
).rr
, _RGB(Particles
(i
).r
, Particles
(i
).g
, Particles
(i
).b
) PAINT (Particles
(i
).
pos.x
, Particles
(i
).
pos.y
), _RGB(Particles
(i
).r
, Particles
(i
).g
, Particles
(i
).b
), _RGB(Particles
(i
).r
, Particles
(i
).g
, Particles
(i
).b
) Particles
(i
).
pos.x
= Particles
(i
).
pos.x
+ Particles
(i
).j
* speed
Particles
(i
).
pos.y
= Particles
(i
).
pos.y
+ Particles
(i
).i
* speed
IF Particles
(i
).
pos.y
> _HEIGHT - Particles
(i
).rr
THEN Particles
(i
).i
= -Particles
(i
).i
IF Particles
(i
).
pos.y
< 0 + Particles
(i
).rr
THEN Particles
(i
).i
= -Particles
(i
).i
IF Particles
(i
).
pos.x
> _WIDTH - Particles
(i
).rr
THEN Particles
(i
).j
= -Particles
(i
).j
IF Particles
(i
).
pos.x
< 0 + Particles
(i
).rr
THEN Particles
(i
).j
= -Particles
(i
).j
' _LIMIT 60
' _glClearColor 1, 1, 1, 1
' _glClear _GL_COLOR_BUFFER_BIT OR _GL_DEPTH_BUFFER_BIT
' _glColor4f 1, 1, 1, .05
IF distance
(Particles
(i
).
pos.x
, Particles
(i
).
pos.y
, Particles
(j
).
pos.x
, Particles
(j
).
pos.y
) < 80 THEN IF distance
(Particles
(j
).
pos.x
, Particles
(j
).
pos.y
, Particles
(n
).
pos.x
, Particles
(n
).
pos.y
) < 80 THEN _glColor4f Particles
(i
).r
/ 255, Particles
(i
).g
/ 255, Particles
(i
).b
/ 255, .1
toGlZ## = map(z#, 0, 100, 0, 1)
FUNCTION map##
(value##
, minRange##
, maxRange##
, newMinRange##
, newMaxRange##
) map## = ((value## - minRange##) / (maxRange## - minRange##)) * (newMaxRange## - newMinRange##) + newMinRange##
FUNCTION distance##
(x1##
, y1##
, x2##
, y2##
) IF x1##
> x2##
THEN dx##
= x1##
- x2##
ELSE dx##
= x2##
- x1##
IF y1##
> y2##
THEN dy##
= y1##
- y2##
ELSE dy##
= y2##
- y1##
distance##
= SQR(dx##
* dx##
+ dy##
* dy##
)