Post by 8XenoTrogdor8 on Feb 13, 2005 20:39:33 GMT -5
I was making an explosion animation for a upcoming game, but decided it looked cool enough to make into its own program. For explanation purposes, this is kinda a screen saver of sorts. You can control the size of cones by pressing the up or down arrow keys, and the number of cones by changing the constant "MaxExplode".
Later!
' From the labs of XenoTrogdor,
' The Dot-Cone Screensaver!
' V 1.00-coneular
Const MaxExplode = 15 ' maximum number of arrays.
Dim I ' main for/next loop variable.
Dim M ' embeded for/next loop variable.
Dim K ' embeded embeded for/next loop variable.
Struc SExplode ' structure name for cone.
Dim turn# ' rotation of cone.
Dim push# ' expansion of cone.
Dim Size# ' maximum expansion of cone.
Dim Pos# (1) ' position of cone on screen.
Dim rgb# (2) ' color of cone.
EndStruc
Dim SExplode Explode (MaxExplode) ' variable name of cone.
Dim Size : Size = 10 ' default size for cones.
Dim HideText : HideText = 250
Dim Brightness : Brightness = FALSE ' point size.
for I = 0 to MaxExplode ' preset random colors, sizes and positions of cones.
Explode (I).pos# = Vec2 ((Rnd () % 40) - 20, (Rnd () % 40) - 20)
Explode (I).Size# = Rnd () % 10
Explode (I).rgb# = Vec3 ((Rnd () % 20) / 10, (Rnd () % 20) / 10, (Rnd () % 20) / 10)
next
While True
Cls
TextMode (TEXT_OVERLAID)
GlClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
GlLoadIdentity () ' reset the viewpoint.
GlTranslatef (0, 0, -500) ' push everything 500 units into screen.
GlRotatef (45, 1, 0, 0) ' rotate everything 45 degrees on X axis.
for I = 0 to MaxExplode
if Explode (I).Size# > .1 then ' determine if cone is finished or not.
GlPushmatrix ()
GlTranslatef (Explode (I).pos# (0) * 10, Explode (I).pos# (1) * 10, Explode (I).Size# * 15) ' translate to cone's position.
GlRotatef (Explode (I).Turn#, 0, 0, 1) ' rotate to current cone rotation.
GlColor3fv (Explode (I).rgb#) ' set the color of the cone.
for M = 1 to 36 ' M relates to the individual lines of dots.
GlPushMatrix ()
GlRotatef (10 * M, 0, 0, 1) ' rotate 10 degrees for each dot.
for K = 1 to 10 ' K relates to individual circles of dots.
GlPushMatrix ()
GlTranslatef (Explode (I).Push#*(K*1.0/20), 0, Explode (I).Push#*(K*1.0/20)) ' place the circles in different positions.
GlBegin (GL_POINTS) ' draw the individual dot.
GlVertex2f (0, 0)
GlEnd ()
GlPopMatrix () ' drop any singular dot transformations and go back to individual lines.
next
GlPopMatrix () ' drop individual lines rotation and go to next line.
next
GlPopmatrix () ' drop current cone transformations and rotations and go to next cone.
Explode (I).rgb# = Explode (I).rgb# * .97 ' dim the cone color.
Explode (I).Turn# = Explode (I).Turn# + Explode (I).Size# ' rotate the cone.
Explode (I).Push# = Explode (I).Push# + Explode (I).Size# ' expand the cone.
Explode (I).Size# = Explode (I).Size# * .96 ' reduce the size value.
else ' if the size is too small to require rendering, reset the cone.
Explode (I).Turn# = 0 ' reset rotation.
Explode (I).Push# = 0 ' reset expansion.
Explode (I).pos# = Vec2 ((Rnd () % 40) - 20, (Rnd () % 40) - 20) ' give it another random position.
Explode (I).rgb# = Vec3 ((Rnd () % 20) / 5, (Rnd () % 20) / 5, (Rnd () % 20) / 5) ' set another random color.
Explode (I).Size# = Rnd () % Size ' randomize the size, up to amount of the varialbe "Size".
endif
next ' go to the next cone.
' increase/decrease point size.
if KeyDown ("B") then Brightness = not Brightness endif
if Brightness then GlPointSize (2) else GlPointSize (1) endif
' increase/decrease maximum size.
if ScanKeyDown (VK_UP) then Size = Size + 1 : HideText = 250 endif
if ScanKeyDown (VK_DOWN) then Size = Size - 1 : HideText = 250 endif
if Size > 20 then Size = 20 endif
if Size < 2 then Size = 2 endif
' dim the text in the corner of the sceen.
if HideText > 10 then HideText = HideText - 10 endif
Color (HideText, HideText, HideText)
Printr "Size " + Size
DrawText ()
SwapBuffers ()
Wend
Later!