home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD40433172000.psc / TicTacToeMainScreen.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2000-03-18  |  4.7 KB  |  147 lines

  1. VERSION 5.00
  2. Begin VB.Form TicTacToeMainScreen 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H80000008&
  5.    Caption         =   "Tic Tac Toe Millennium Edition"
  6.    ClientHeight    =   6570
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   8835
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   438
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   589
  15.    StartUpPosition =   2  'CenterScreen
  16.    WindowState     =   2  'Maximized
  17.    Begin VB.PictureBox picTiles 
  18.       Appearance      =   0  'Flat
  19.       AutoRedraw      =   -1  'True
  20.       AutoSize        =   -1  'True
  21.       BackColor       =   &H80000005&
  22.       ForeColor       =   &H80000008&
  23.       Height          =   4935
  24.       Left            =   600
  25.       Picture         =   "TicTacToeMainScreen.frx":0000
  26.       ScaleHeight     =   329.669
  27.       ScaleMode       =   0  'User
  28.       ScaleWidth      =   492
  29.       TabIndex        =   2
  30.       Top             =   1560
  31.       Visible         =   0   'False
  32.       Width           =   7410
  33.    End
  34.    Begin VB.PictureBox picMain 
  35.       Appearance      =   0  'Flat
  36.       AutoRedraw      =   -1  'True
  37.       AutoSize        =   -1  'True
  38.       BackColor       =   &H80000006&
  39.       ForeColor       =   &H80000008&
  40.       Height          =   3720
  41.       Left            =   0
  42.       ScaleHeight     =   248.008
  43.       ScaleMode       =   0  'User
  44.       ScaleWidth      =   738
  45.       TabIndex        =   0
  46.       Top             =   1440
  47.       Width           =   11100
  48.    End
  49.    Begin VB.PictureBox picDetection 
  50.       Appearance      =   0  'Flat
  51.       AutoRedraw      =   -1  'True
  52.       AutoSize        =   -1  'True
  53.       BackColor       =   &H80000006&
  54.       ForeColor       =   &H80000008&
  55.       Height          =   3720
  56.       Left            =   240
  57.       Picture         =   "TicTacToeMainScreen.frx":75DA0
  58.       ScaleHeight     =   248.008
  59.       ScaleMode       =   0  'User
  60.       ScaleWidth      =   738
  61.       TabIndex        =   1
  62.       Top             =   720
  63.       Visible         =   0   'False
  64.       Width           =   11100
  65.    End
  66. Attribute VB_Name = "TicTacToeMainScreen"
  67. Attribute VB_GlobalNameSpace = False
  68. Attribute VB_Creatable = False
  69. Attribute VB_PredeclaredId = True
  70. Attribute VB_Exposed = False
  71. Option Explicit
  72. Private Sub BBBoard(SquareNo As Long, X As Long, Y As Long, BlueOrWhite As Long)
  73.   BitBlt picMain.hdc, X, Y, TileSizeX, TileSizeY, picTiles.hdc, 0, 246, BBMASK
  74.   BitBlt picMain.hdc, X, Y, TileSizeX, TileSizeY, picTiles.hdc, 246 * BlueOrWhite, 82 * GD.Board(SquareNo), BBPAINT
  75. End Sub
  76. Private Sub DrawBoard()
  77.   picMain.Cls
  78.   BBBoard 1, 246, 0, 0
  79.   BBBoard 2, 369, 41, 1
  80.   BBBoard 3, 492, 82, 0
  81.   BBBoard 4, 123, 41, 1
  82.   BBBoard 5, 246, 82, 0
  83.   BBBoard 6, 369, 123, 1
  84.   BBBoard 7, 0, 82, 0
  85.   BBBoard 8, 123, 123, 1
  86.   BBBoard 9, 246, 164, 0
  87.   If GD.CurrentBoardNo > 0 Then
  88.     If GD.Board(GD.CurrentBoardNo) = 0 Then
  89.       BitBlt picMain.hdc, GD.Current.X, GD.Current.Y, TileSizeX, TileSizeY, picTiles.hdc, 0, 246, BBMASK
  90.       BitBlt picMain.hdc, GD.Current.X, GD.Current.Y, TileSizeX, TileSizeY, picTiles.hdc, BlueX, 246, BBPAINT
  91.     End If
  92.   End If
  93.   picMain.Refresh
  94.   'DoEvents
  95. End Sub
  96. Private Sub Form_Load()
  97.   Resetboard
  98.   GD.CurrentPlayer = 1
  99. End Sub
  100. Private Sub Form_Resize()
  101.   picMain = picDetection
  102.   If Me.WindowState = 0 Then Me.WindowState = 2
  103.   If Not Me.WindowState = 2 Then Exit Sub
  104.   Me.picMain.Top = Int((Me.ScaleHeight) - (Me.picMain.ScaleHeight)) / 2
  105.   Me.picMain.Left = Int((Me.ScaleWidth) - (Me.picMain.ScaleWidth)) / 2
  106.   Me.picDetection.Top = Me.picMain.Top
  107.   Me.picDetection.Left = Me.picMain.Left
  108.   DrawBoard
  109. End Sub
  110. Private Sub picMain_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  111.     If CheckBoardFull Then
  112.       DrawBoard
  113.       MsgBox "No winner"
  114.       Resetboard
  115.     End If
  116.   If GD.CurrentPlayer = 1 Then
  117.     If GD.CurrentBoardNo = 0 Then Exit Sub
  118.     If GD.Board(GD.CurrentBoardNo) > 0 Then Exit Sub
  119.     GD.Board(GD.CurrentBoardNo) = GD.CurrentPlayer
  120.     If GameWon(1) Then
  121.       DrawBoard
  122.       MsgBox "Player " & GD.CurrentPlayer & " Wins"
  123.       Resetboard
  124.     End If
  125.     GD.CurrentPlayer = 2
  126.     picMain_MouseDown 0, 0, 0, 0
  127.   Else
  128.     ComputersGo
  129.     If GameWon(2) Then
  130.       DrawBoard
  131.       MsgBox "Computer Wins"
  132.       Resetboard
  133.     End If
  134.     If CheckBoardFull Then
  135.       DrawBoard
  136.       MsgBox "No winner"
  137.       Resetboard
  138.     End If
  139.     GD.CurrentPlayer = 1
  140.   End If
  141.   DrawBoard
  142. End Sub
  143. Private Sub picMain_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  144.   SetCurrentSquare picDetection.Point(X, Y)
  145.   DrawBoard
  146. End Sub
  147.