|
Post by Nicky Peter Hollyoake on Jul 19, 2016 20:31:59 GMT -5
dim w=150, h=90
glMatrixMode(GL_PROJECTION) glLoadidentity() gluOrtho2d(0, w, h, 0) glMatrixMode(GL_MODELVIEW) glDisable(GL_DEPTH_TEST) glDisable(GL_CULL_FACE) ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' declare sub pixel(x, y)
const maxB=6 -1
struc sBlob x, y, r v#(1) endstruc
dim x, y, i dim sBlob b(maxB) dim c#, d#, r#
for i = 0 to maxB b(i).x = rnd() % w b(i).y = rnd() % h r# = rnd()%4 if r#=0 then b(i).v# = vec2( 1, 1) elseif r#=1 then b(i).v# = vec2(-1, 1) elseif r#=2 then b(i).v# = vec2( 1,-1) elseif r#=3 then b(i).v# = vec2(-1,-1) endif
b(i).r = 3 + rnd() % 5 next
while true glClear(GL_DEPTH_BUFFER_BIT)
for y = 0 to h-1 for x = 0 to w-1 c#=0 for i = 0 to maxB d# = sqr(pow(x-b(i).x, 2) + pow(y-b(i).y, 2)) c# = c# + b(i).r/d# next
glColor3f(c#, c#, c#) pixel(x, y) next next
swapbuffers()
for i = 0 to maxB b(i).x = b(i).x + b(i).v#(0) b(i).y = b(i).y + b(i).v#(1)
if b(i).x < 0 or b(i).x > w then b(i).v#(0) = - b(i).v#(0) endif
if b(i).y < 0 or b(i).y > h then b(i).v#(1) = - b(i).v#(1) endif next wend
sub pixel(x, y) glBegin(GL_QUADS) glVertex2f(x, y) glVertex2f(x + 1, y) glVertex2f(x + 1, y + 1) glVertex2f(x, y + 1) glEnd() endsub
You see the effect when 2 balls collide. The actual effect itself does meant to look a lot more detailed but I can't currently find any way to have a higher resolution and speed up the program.
- Nicky
|
|
|
Post by matthew on Jul 20, 2016 3:13:44 GMT -5
I wish my computer would work for more than a few minutes, so I could actually run this program. Sent from my Alba 7" using proboards
|
|