Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  2. Randomize , 1
  3.  
  4. Const fpslimit = 100
  5. Const pi = 3.1415926535897
  6.  
  7. Dim As Integer scrw = 800, scrh = 600
  8. Dim As UByte charh = 8, charw = 8
  9.  
  10.  
  11. ScreenRes scrw, scrh, 8
  12. Dim xcol As ubyte
  13. Dim ycol As Integer
  14.  
  15.  
  16. Dim As Double frameintv = 1.0 / fpslimit
  17. Dim As Integer sleepintv
  18. Dim As Double TimeStart
  19. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  20.  
  21. 'Set the pallete
  22. Do
  23.     xcol += 1
  24.     If xcol < 64 Then
  25.         Palette xcol, 4*xcol, xcol, 0
  26.     Else
  27.         If xcol > 180 Then
  28.             ycol = ycol + 3
  29.         EndIf
  30.         Palette xcol, 255, xcol, ycol
  31.     EndIf
  32. Loop Until xcol = 255
  33.  
  34. 'rotater var, and positioning the fps meter
  35. Dim x As UInteger
  36. Dim As Integer fpsx, fpsy
  37. 'fps coutner stuff
  38. Dim As Integer fps, fps2, seconds
  39. Dim As double starttime
  40.  
  41. 'Spinning dot vars
  42. Dim As Integer radius = 80
  43. Dim As Double OldX, OldY, Angle = (-11 * .017453)
  44. Dim As Double XX, YY = radius
  45. Dim As Integer VX = (scrw / 2), VY = (scrh / 2)
  46.  
  47. 'filter vars
  48. Dim As Integer filter(scrw,scrh), flx, fly, flz, newcolor
  49.  
  50. 'Put the fps in the corner
  51. fpsx = (scrw - Len(Str(fps2))*charw) - 10
  52. fpsy = (scrh - charh) - 10
  53.  
  54. 'Random line at bottom
  55. Dim liner As Integer
  56.  
  57. ''''' DO '''''
  58. Do
  59. 'Lay the timer start
  60. TimeStart = Timer
  61.  
  62. 'Get ready to draw!
  63. ScreenLock
  64.  
  65. '' Lets spin a dot!
  66. ' If I want to spin a dot 360* per second, and there are 30
  67. ' frames in a second, then I need to move 360 / 30 degrees per frame
  68.  
  69. ' radians = degrees * pi / 180
  70. ' degrees = radians * 180 / pi
  71.  
  72. OldX = XX
  73. OldY = YY
  74. XX = (OldX * Cos(Angle)) + (OldY * Sin(Angle))
  75. YY = (OldY * Cos(Angle)) - (OldX * Sin(Angle))
  76.  
  77. Circle(XX + VX, YY + VY), 5, 255
  78.  
  79. 'Some dots for flavor
  80. For liner = 1 To scrw
  81.     PSet(liner, scrh-1), (Rnd * 255)
  82. Next
  83.  
  84. ''' Filter time! '''
  85. 'Dim As Integer filter(scrw,scrh), flx, fly, flz, newcolor'
  86. For flx = 1 To scrw
  87.     For fly = 1 To scrh
  88.        
  89.         If (fly > scrh-2) Then
  90.             newcolor = 0
  91.             filter(flx, fly) = newcolor
  92.         Else
  93.             newcolor = (Point(flx, fly + 1) + Point(flx + 1, fly + 1) + _
  94.             Point(flx - 1, fly + 1) + Point(flx, fly + 2)) / 5
  95.             filter(flx, fly) = newcolor
  96.         EndIf
  97.        
  98.    
  99.        
  100.     Next
  101. Next
  102.  
  103. For flx = 1 To scrw
  104.     For fly = 1 To scrh
  105.             PSet(flx, fly), filter(flx, fly)
  106.     Next
  107. Next
  108.  
  109.  
  110. 'draw the FPS
  111. Draw String (fpsx, fpsy), Str(fps2 - 1), 255
  112.  
  113. ScreenUnLock
  114.  
  115.  
  116. 'Adjust our time per frame to 1 / fpslimit
  117. sleepintv = CInt((TimeStart + frameintv - Timer)*1000.0)
  118. If sleepintv > 1 Then
  119.     Sleep sleepintv
  120. Else
  121.     'memory usage!
  122.     Sleep 1
  123. EndIf
  124.  
  125. 'Calculate actual FPS
  126. fps += 1
  127. If starttime + 1 < Timer Then
  128.     fps2 = fps
  129.     fps = 0
  130.     seconds += 1
  131.     starttime = Timer
  132. EndIf
  133.  
  134. Loop Until Inkey <> ""
  135.  
  136. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement