Also try with max=50.

I made this prototype for part of another prototype I'm making. :P

Code: Select all

`' Dot Clusters By Kristopher Windsor`

#include once "fbgfx.bi"

const sx = 800, sy = 600

const max = 5 'circles total

const gs = 100 'line length

type p

as double x, y

end type

dim shared as p c(1 to max)

randomize()

for i as integer = 1 to max

with c(i)

.x = sx * rnd()

.y = sy * rnd()

end with

next i

dim as integer mx, my, mb

screenres sx, sy, 32,, fb.GFX_ALPHA_PRIMITIVES

do

'move

for i as integer = 1 to max

for j as integer = 1 to max

if i = j then continue for

var a = @c(i)

var b = @c(j)

var dist = sqr((a->x - b->x) ^ 2 + (a->y - b->y) ^ 2)

if dist > .000001 then

var grow = (10 + gs / dist) / 11

var cx = (a->x + b->x) / 2

var cy = (a->y + b->y) / 2

a->x = cx + (a->x - cx) * grow

a->y = cy + (a->y - cy) * grow

b->x = cx + (b->x - cx) * grow

b->y = cy + (b->y - cy) * grow

end if

next j

next i

getmouse(mx, my,, mb)

if mb > 0 then c(1).x = mx : c(1).y = my

if multikey(fb.sc_up) then c(2).y -= 20

if multikey(fb.sc_down) then c(2).y += 20

if multikey(fb.sc_left) then c(2).x -= 20

if multikey(fb.sc_right) then c(2).x += 20

'display

screenlock()

cls()

for i as integer = 1 to max

var j = (i mod max) + 1

circle (c(i).x, c(i).y), 8, &HFFFFFFFF,,, 1, F

next i

for i as integer = 1 to max

for j as integer = i + 1 to max

if i = j then continue for

line (c(i).x, c(i).y) - (c(j).x, c(j).y), &H400000FF

next j

next i

screenunlock()

sleep(18, 1)

loop until inkey() = chr(27)