Post by 8XenoTrogdor8 on Oct 15, 2004 4:10:11 GMT -5
I'm not sure what inspired me to make this demo, but I guess it got made anyway. It's neat because it employs some real life physics in the way the water (or small blue squares) is projected from the 5 sided fountain. These physics might not be very accurate, though...
There's a slight problem with the way the first few loops begin, though. The water shoots up way too high! Darned unregulated water pressure anyway.
Programming Rocks!
'From the lab of XenoTrogdor,
'the one, the only, 5 sided fountain program!
const drops = 180
const forceY# = .7
const forceX# = .1
const gravity# = .03
dim random#
dim rotate#
dim x#(drops)
dim y#(drops)
dim camerarotate#
dim vforce#(drops)
dim i
'randomize the waterdrops. well, somewhat randomize. this part needs work:)
for i = 1 to drops
vforce#(i) = forceY# + random#/10
random# = (rnd () %10)
next
while true
glLoadIdentity ()
glClearColor(0, 0, .3, 1)
glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
glTranslatef (0, 0, -20)
glRotatef (camerarotate#, 0, 1, 0)
camerarotate# = camerarotate# + 1
'-------------------------Ground and Fountain-----------------------------'
glBegin (GL_QUADS)
glColor3f (.3, .3, .4)
glVertex3f (.4, 0, -.7)
glVertex3f (-.4, 0, -.7)
glVertex3f (-.8, -5, -1.4)
glVertex3f (.8, -5, -1.4)
glVertex3f (-.8, 0, 0)
glVertex3f (-.4, 0, -.7)
glVertex3f (-.8, -5, -1.4)
glVertex3f (-1.6, -5, 0)
glVertex3f (0, 0, .4)
glVertex3f (-.8, 0, 0)
glVertex3f (-1.6, -5, 0)
glVertex3f (0, -5, .8)
glVertex3f (.8, 0, 0)
glVertex3f (0, 0, .4)
glVertex3f (0, -5, .8)
glVertex3f (1.6, -5, 0)
glVertex3f (.4, 0, -.7)
glVertex3f (.8, 0, 0)
glVertex3f (1.6, -5, 0)
glVertex3f (.8, -5, -1.4)
glEnd ()
glBegin (GL_QUADS)
glColor3f (0, .7, 0)
glVertex3f (30, -5, 30)
glVertex3f (30, -5, -30)
glVertex3f (-30, -5, -30)
glVertex3f (-30, -5, 30)
glEnd ()
'------------------------------Water drops--------------------------------'
for i = 1 to drops
'reset drop after it hits ground level.
if y#(i) <= -5 then
x#(i) = 0
y#(i) = 0
vforce#(i) = forceY#
endif
glRotatef ((5*i), 0, 1, 0)
glBegin (GL_QUADS)
glColor3f (0, 0, 1)
glVertex2f (0 + x#(i), 0 + y#(i))
glVertex2f (.1 + x#(i), 0 + y#(i))
glVertex2f (.1 + x#(i), .1 + y#(i))
glVertex2f (0 + x#(i), .1 + y#(i))
glEnd ()
'add the forces and gravity into the equation! isn't physics great?
x#(i) = x#(i) + forceX#
y#(i) = y#(i) + vforce#(i)
vforce#(i) = vforce#(i) - gravity#
next
SwapBuffers ()
wend
There's a slight problem with the way the first few loops begin, though. The water shoots up way too high! Darned unregulated water pressure anyway.
Programming Rocks!