home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 December / DPPCPRO1205.ISO / Essentials / Programming / Basic4GL / Setup Basic4GL v2.3.1.exe / $INSTDIR / Programs / Stars.gb < prev    next >
Encoding:
Text File  |  2005-07-29  |  1.8 KB  |  69 lines

  1. const balls = 75
  2. dim x#(balls), y#(balls), z#(balls), mag#(balls), r(balls), g(balls), b(balls), scale#(balls)
  3. dim brightness
  4. dim texStar
  5. dim t, t2, t3, zOffset#, zLimit#
  6. dim vz#
  7.  
  8. brightness = 2: zLimit# = 50
  9.  
  10. texStar = LoadMipmapTexture ("data\star.bmp")
  11.  
  12. for t = 0 to balls 
  13.     x#(t) = (rnd()%2000-1000)/100.0
  14.     y#(t) = (rnd()%2000-1000)/100.0
  15.     z#(t) = (rnd()%2000     )/1000.0*zLimit#
  16.     r(t)  = rnd()%196+64 
  17.     g(t)  = rnd()%196+64 
  18.     b(t)  = rnd()%196+64 
  19.     scale#(t)=(rnd()%1000)/200.0
  20. next
  21.  
  22. glEnable (GL_TEXTURE_2D)
  23. glBindTexture (GL_TEXTURE_2D, texStar)
  24. glEnable (GL_BLEND)
  25. glBlendFunc (GL_SRC_COLOR, GL_ONE)
  26. glDisable (GL_DEPTH_TEST)
  27.  
  28. while true
  29.     glClear (GL_DEPTH_BUFFER_BIT or GL_COLOR_BUFFER_BIT)
  30.     glLoadIdentity ()
  31.     
  32.     for t = 1 to balls
  33.         
  34.         glPushMatrix ()
  35.         zOffset# = z#(t) - vz#
  36.         zOffset# = zOffset# - zLimit# * Int (zOffset# / zLimit#)
  37.         if zOffset# < 0 then 
  38.             zOffset# = zOffset# + zLimit#
  39.         endif
  40.         
  41.         glTranslatef (x#(t), y#(t), -zOffset#)
  42.         glScalef (scale#(t), scale#(t), scale#(t))
  43.  
  44.         for t2 = 1 to brightness
  45.             t3 = (t+t2)%balls            
  46.             glColor3ub (r(t3), g(t3), b(t3))
  47.             glBegin (GL_QUADS)
  48.                 glTexCoord2f (1, 0):    glVertex2f ( 1, 1)
  49.                 glTexCoord2f (0, 0):    glVertex2f (-1, 1)
  50.                 glTexCoord2f (0, 1):    glVertex2f (-1,-1)
  51.                 glTexCoord2f (1, 1):    glVertex2f ( 1,-1)
  52.             glEnd ()
  53.             glRotatef (45, 0, 0, 1)
  54.         next
  55.         glPopMatrix ()
  56.     next
  57.     SwapBuffers ()
  58.  
  59. '    WaitTimer (10)
  60. '    gosub Animate
  61.     while SyncTimer (20)
  62.         gosub Animate
  63.     wend
  64. wend
  65. end
  66.  
  67. Animate:
  68.     vz# = vz# + 0.2
  69.     return