Author Topic: Cloudy forces  (Read 96 times)

John

  • Sr. Member
  • ****
  • Posts: 362
    • View Profile
Cloudy forces
« on: September 08, 2017 »
Random code :)

Code: [Select]
import "Random.lib"
import "ifx.lib"

constant:
FORCE_X 0
FORCE_Y 1
FORCE_R 2
FORCE_DX 3
FORCE_DY 4
FORCE_PARAM 5

PRT_X 0
PRT_Y 1
PRT_DX 2
PRT_DY 3

BG_R 128
BG_G 32
BG_B 0

hidden:

if not IFX_Init() then end

forces#[8][6]
for i = 0 to sizeof(forces, 0) - 1
forces[i][FORCE_X] = RandomFloat(640.0 + 100.0) - 50.0
forces[i][FORCE_Y] = RandomFloat(480.0 + 100.0) - 50.0
forces[i][FORCE_R] = 100.0 + RandomFloat(200.0)
a# = RandomFloat(360.0)
spd# = 2.0 + RandomFloat(3.0)
forces[i][FORCE_DX] = cos(a)*spd
forces[i][FORCE_DY] = sin(a)*spd
forces[i][FORCE_PARAM] = RandomFloat(1.0)
next

particles#[512][4]
for i = 0 to sizeof(particles, 0) - 1
particles[i][PRT_X] = RandomFloat(640.0)
particles[i][PRT_Y] = RandomFloat(480.0)
particles[i][PRT_DX] = 0.0
particles[i][PRT_DY] = 0.0
next

set redraw off

set color BG_R, BG_G, BG_B
cls

do
for i = 0 to sizeof(forces, 0) - 1
forces[i][FORCE_PARAM] = forces[i][FORCE_PARAM] + 0.005
if forces[i][FORCE_PARAM] >= 1.0
forces[i][FORCE_PARAM] = 0.0
forces[i][FORCE_X] = RandomFloat(640.0 + 100.0) - 50.0
forces[i][FORCE_Y] = RandomFloat(480.0 + 100.0) - 50.0
a# = RandomFloat(360.0)
spd# = 2.0 + RandomFloat(3.0)
forces[i][FORCE_DX] = cos(a)*spd
forces[i][FORCE_DY] = sin(a)*spd
forces[i][FORCE_R] = 100.0 + RandomFloat(200.0)
endif
s# = sin(forces[i][FORCE_PARAM]*180.0)
r# = forces[i][FORCE_R]*s
forces[i][FORCE_X] = forces[i][FORCE_X] + forces[i][FORCE_DX]*s
forces[i][FORCE_Y] = forces[i][FORCE_Y] + forces[i][FORCE_DY]*s
r = r*r
for j = 0 to sizeof(particles, 0) - 1
dx# = particles[j][PRT_X] - forces[i][FORCE_X]
dy# = particles[j][PRT_Y] - forces[i][FORCE_Y]
'd# = sqr(dx*dx + dy*dy)
d# = dx*dx + dy*dy
if d < r
k# = (r - d)/r
particles[j][PRT_DX] = particles[j][PRT_DX] + dx*k*0.01
particles[j][PRT_DY] = particles[j][PRT_DY] + dy*k*0.01
endif
next
next

for i = 0 to sizeof(particles, 0) - 1
particles[i][PRT_DX] = particles[i][PRT_DX]*0.99
particles[i][PRT_DY] = particles[i][PRT_DY]*0.99
particles[i][PRT_X] = particles[i][PRT_X] + particles[i][PRT_DX]
particles[i][PRT_Y] = particles[i][PRT_Y] + particles[i][PRT_DY]
if particles[i][PRT_X] < 0.0
particles[i][PRT_X] = 0.0
particles[i][PRT_DX] = abs#(particles[i][PRT_DX])
endif
if particles[i][PRT_Y] < 0.0
particles[i][PRT_Y] = 0.0
particles[i][PRT_DY] = abs#(particles[i][PRT_DY])
endif
if particles[i][PRT_X] > 640.0
particles[i][PRT_X] = 640.0
particles[i][PRT_DX] = -abs#(particles[i][PRT_DX])
endif
if particles[i][PRT_Y] > 480.0
particles[i][PRT_Y] = 480.0
particles[i][PRT_DY] = -abs#(particles[i][PRT_DY])
endif
next

set color BG_R, BG_G, BG_B, 2
cls
set color 255, 200, 128
for i = 0 to sizeof(particles, 0) - 1
' draw pixel int(particles[i][PRT_X]), int(particles[i][PRT_Y])
draw rect int(particles[i][PRT_X]) - 2, int(particles[i][PRT_Y]) - 2, 4, 4, true
next

_IFX_Blur 12

redraw
wait 16
until keydown(27, true)
« Last Edit: September 08, 2017 by John »

Rick3137

  • Sr. Member
  • ****
  • Posts: 347
  • May the Force be with You
    • View Profile
    • Rick's Programs
Re: Cloudy forces
« Reply #1 on: September 08, 2017 »
 Wow...
 It looks like Hurricane Irma. 180 mph winds.