home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / visual2a / blackboa.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-09-25  |  6.9 KB  |  215 lines

  1. VERSION 5.00
  2. Begin VB.Form BlackBoard 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00000000&
  5.    BorderStyle     =   0  'None
  6.    Caption         =   "Black Board!"
  7.    ClientHeight    =   1935
  8.    ClientLeft      =   4875
  9.    ClientTop       =   6345
  10.    ClientWidth     =   3615
  11.    Icon            =   "BlackBoard.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   1935
  16.    ScaleWidth      =   3615
  17.    WindowState     =   2  'Maximized
  18.    Begin VB.Timer Timer1 
  19.       Enabled         =   0   'False
  20.       Interval        =   3
  21.       Left            =   120
  22.       Top             =   120
  23.    End
  24. Attribute VB_Name = "BlackBoard"
  25. Attribute VB_GlobalNameSpace = False
  26. Attribute VB_Creatable = False
  27. Attribute VB_PredeclaredId = True
  28. Attribute VB_Exposed = False
  29. Sub Calc(Op As Integer)
  30. '********************************************************
  31. 'This is where all happens
  32. '********************************************************
  33. 'Declare local static variabled required for the program
  34.     Static X(7) As Integer, Y(7) As Integer
  35.     Static T1(7) As Integer, T2(7) As Integer
  36.     Static Maxx As Long, Maxy As Long
  37.     Static C(3) As Integer, CP(3) As Integer
  38. 'Get the Forms Size and take 5 twips
  39.     Maxx = Me.Width - 5
  40.     Maxy = Me.Height - 5
  41. '1st time. Set the variables values
  42.     If Op = 1 Then
  43. 'Start the random number generator
  44.         Randomize
  45. 'Update the "coordinate points" variables
  46.         T1(0) = Int(Rnd * Maxx)
  47.         T1(1) = Int(Rnd * Maxy)
  48.         T1(2) = Int(Rnd * Maxx)
  49.         T1(3) = Int(Rnd * Maxy)
  50.         T1(4) = Int(Rnd * Maxx)
  51.         T1(5) = Int(Rnd * Maxy)
  52.         T1(6) = Int(Rnd * Maxx)
  53.         T1(7) = Int(Rnd * Maxy)
  54. 'Update the "delocation factor" variables
  55.         X(0) = 60
  56.         Y(0) = 80
  57.         X(1) = 80
  58.         Y(1) = 100
  59.         X(2) = 100
  60.         Y(2) = 60
  61.         X(3) = 90
  62.         Y(3) = 90
  63. 'Update the "gradient color" variables
  64.         C(1) = Int(Rnd * 256)
  65.         C(2) = Int(Rnd * 256)
  66.         C(3) = Int(Rnd * 256)
  67. 'Update the "gradient factor" variables
  68.         CP(1) = 2
  69.         CP(2) = 3
  70.         CP(3) = 4
  71. 'Do the next code
  72.         Op = 2
  73.     End If
  74.     If Op = 2 Then
  75. 'Update the "points coordinates" variables
  76.         T2(0) = T1(0)
  77.         T2(1) = T1(1)
  78.         T2(2) = T1(2)
  79.         T2(3) = T1(3)
  80.         T2(4) = T1(4)
  81.         T2(5) = T1(5)
  82.         T2(6) = T1(6)
  83.         T2(7) = T1(7)
  84.         X(4) = X(0)
  85.         Y(4) = Y(0)
  86.         X(5) = X(1)
  87.         Y(5) = Y(1)
  88.         X(6) = X(2)
  89.         Y(6) = Y(2)
  90.         X(7) = X(3)
  91.         Y(7) = Y(3)
  92. 'Set the "left trails" variable to 0
  93.         A = 0
  94. 'Clear the screen
  95.         Me.Cls
  96.     End If
  97. 'Check if the "gradient factor" variables are between 0
  98. 'and 255 and update the "gradient color" variables
  99.     For I = 1 To 3
  100.         If C(I) + CP(I) < 0 Or C(I) + CP(I) > 255 Then CP(I) = -CP(I)
  101.         C(I) = C(I) + CP(I)
  102.     Next I
  103. 'Draw the Polygon
  104.     Dpoly T1, RGB(C(1), C(2), C(3))
  105. 'Check if the points have colided with the border of the
  106. 'screen. If so update the "delocation factor" variables
  107.     If T1(0) < 1 Or T1(0) > Maxx Then X(0) = -X(0)
  108.     If T1(2) < 1 Or T1(2) > Maxx Then X(1) = -X(1)
  109.     If T1(4) < 1 Or T1(4) > Maxx Then X(2) = -X(2)
  110.     If T1(6) < 1 Or T1(6) > Maxx Then X(3) = -X(3)
  111.     If T1(1) < 1 Or T1(1) > Maxy Then Y(0) = -Y(0)
  112.     If T1(3) < 1 Or T1(3) > Maxy Then Y(1) = -Y(1)
  113.     If T1(5) < 1 Or T1(5) > Maxy Then Y(2) = -Y(2)
  114.     If T1(7) < 1 Or T1(7) > Maxy Then Y(3) = -Y(3)
  115. 'Check if the "delete trails" variable is true
  116.     If DelLines = True Then
  117. 'If so, check if the "lefted trails" variable is bigger
  118. 'than the "trails size" variable
  119.         If A > RST Then
  120. 'If so, delete the old trails, by drawing a black polygon
  121. 'over them
  122.             Dpoly T2, 0
  123. 'Update the 2nd poly "coordinate points" variables as
  124. 'with the 1st
  125.             If T2(0) < 1 Or T2(0) > Maxx Then X(4) = -X(4)
  126.             If T2(2) < 1 Or T2(2) > Maxx Then X(5) = -X(5)
  127.             If T2(4) < 1 Or T2(4) > Maxx Then X(6) = -X(6)
  128.             If T2(6) < 1 Or T2(6) > Maxx Then X(7) = -X(7)
  129.             If T2(1) < 1 Or T2(1) > Maxy Then Y(4) = -Y(4)
  130.             If T2(3) < 1 Or T2(3) > Maxy Then Y(5) = -Y(5)
  131.             If T2(5) < 1 Or T2(5) > Maxy Then Y(6) = -Y(6)
  132.             If T2(7) < 1 Or T2(7) > Maxy Then Y(7) = -Y(7)
  133.             T2(0) = T2(0) + X(4)
  134.             T2(1) = T2(1) + Y(4)
  135.             T2(2) = T2(2) + X(5)
  136.             T2(3) = T2(3) + Y(5)
  137.             T2(4) = T2(4) + X(6)
  138.             T2(5) = T2(5) + Y(6)
  139.             T2(6) = T2(6) + X(7)
  140.             T2(7) = T2(7) + Y(7)
  141.         Else
  142. 'Update the "left trails" variable
  143.             A = A + 1
  144.         End If
  145.     End If
  146. 'Update the 1st polygon "coordinate points" variables
  147.     T1(0) = T1(0) + X(0)
  148.     T1(1) = T1(1) + Y(0)
  149.     T1(2) = T1(2) + X(1)
  150.     T1(3) = T1(3) + Y(1)
  151.     T1(4) = T1(4) + X(2)
  152.     T1(5) = T1(5) + Y(2)
  153.     T1(6) = T1(6) + X(3)
  154.     T1(7) = T1(7) + Y(3)
  155. 'Do the cached events
  156.     DoEvents
  157. End Sub
  158. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  159.     Static T As Double, S As String
  160. 'Protect against accidental Mouse Moving
  161.     If T = 0 Then
  162.         T = Timer + 0.2
  163.     ElseIf Timer > T And SS = True Then
  164. 'Stop drawing
  165.         Timer1.Enabled = False
  166. 'Check if the "require password" variable is true and
  167. 'there is a valid password
  168.         If P = True And PSWD <> "" Then
  169. 'If so, ask for the password
  170.             S = InputBox("Please enter the PassWord:", "Exit!", "")
  171. 'Check if Cancel was pressed or an incorrect password
  172. 'was entered
  173.             If S = "" Or S <> PSWD Then
  174. 'If Cancel wasn't pressed show an Error Message Box
  175.                 If S <> "" Then MsgBox "Incorrect PassWord!", vbApplicationModal + vbCritical, "Exit!"
  176. 'Restart drawing and exit this Sub
  177.                 Timer1.Enabled = True
  178.                 T = 0
  179.                 Exit Sub
  180.             End If
  181.         End If
  182. 'Unload the program
  183.         Unload Menu
  184.         Unload BlackBoard
  185.     End If
  186. End Sub
  187. Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  188. 'Check if right button was pressed and not in Screen
  189. 'Saver Mode
  190.     If Button = 2 And SS = False Then
  191. 'Stop drawing and the the submenu
  192.         Timer1.Enabled = False
  193.         Me.PopupMenu Menu.mnuFile, , X, Y
  194.     Else
  195. 'Else, continue drawing the mistify polygons
  196.         Timer1.Enabled = True
  197.     End If
  198. End Sub
  199. Private Sub Form_Unload(Cancel As Integer)
  200. 'Show the cursor
  201.     ShowCursor 1
  202. End Sub
  203. Private Sub Timer1_Timer()
  204. 'Draw the mistify polygons
  205.     Calc (0)
  206. End Sub
  207. Sub Dpoly(P() As Integer, C As Long)
  208.     Dim I As Integer
  209. 'Draw the lines that delimit the polygon
  210.     For I = 0 To (Pts - 2) * 2 Step 2
  211.         Line (P(I), P(I + 1))-(P(I + 2), P(I + 3)), C
  212.     Next I
  213.     Line (P(I), P(I + 1))-(P(0), P(1)), C
  214. End Sub
  215.