home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / Simplixx_-191141792005.psc / frmMain.frm < prev    next >
Text File  |  2005-07-09  |  59KB  |  1,665 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Simplixx"
  6.    ClientHeight    =   5625
  7.    ClientLeft      =   150
  8.    ClientTop       =   720
  9.    ClientWidth     =   4665
  10.    ForeColor       =   &H00808080&
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   375
  15.    ScaleMode       =   3  'Pixel
  16.    ScaleWidth      =   311
  17.    StartUpPosition =   3  'Windows Default
  18.    Begin VB.Timer tmrFlash 
  19.       Interval        =   100
  20.       Left            =   3480
  21.       Top             =   3840
  22.    End
  23.    Begin VB.PictureBox picNext 
  24.       Appearance      =   0  'Flat
  25.       AutoRedraw      =   -1  'True
  26.       BackColor       =   &H00000000&
  27.       BorderStyle     =   0  'None
  28.       ForeColor       =   &H80000008&
  29.       Height          =   975
  30.       Left            =   2880
  31.       ScaleHeight     =   65
  32.       ScaleMode       =   3  'Pixel
  33.       ScaleWidth      =   97
  34.       TabIndex        =   9
  35.       Top             =   480
  36.       Width           =   1455
  37.    End
  38.    Begin VB.PictureBox picBlocks 
  39.       AutoRedraw      =   -1  'True
  40.       AutoSize        =   -1  'True
  41.       BorderStyle     =   0  'None
  42.       Height          =   255
  43.       Left            =   1560
  44.       Picture         =   "frmMain.frx":0E42
  45.       ScaleHeight     =   17
  46.       ScaleMode       =   3  'Pixel
  47.       ScaleWidth      =   204
  48.       TabIndex        =   0
  49.       Top             =   5040
  50.       Visible         =   0   'False
  51.       Width           =   3060
  52.    End
  53.    Begin VB.PictureBox picGrid 
  54.       AutoRedraw      =   -1  'True
  55.       BackColor       =   &H00000000&
  56.       BorderStyle     =   0  'None
  57.       Height          =   5355
  58.       Left            =   120
  59.       ScaleHeight     =   357
  60.       ScaleMode       =   3  'Pixel
  61.       ScaleWidth      =   170
  62.       TabIndex        =   1
  63.       Top             =   120
  64.       Width           =   2550
  65.       Begin VB.Label lblPaused 
  66.          Alignment       =   2  'Center
  67.          BackStyle       =   0  'Transparent
  68.          Caption         =   "Paused"
  69.          BeginProperty Font 
  70.             Name            =   "MS Sans Serif"
  71.             Size            =   13.5
  72.             Charset         =   0
  73.             Weight          =   400
  74.             Underline       =   0   'False
  75.             Italic          =   0   'False
  76.             Strikethrough   =   0   'False
  77.          EndProperty
  78.          ForeColor       =   &H0000FF00&
  79.          Height          =   495
  80.          Left            =   240
  81.          TabIndex        =   12
  82.          Top             =   1080
  83.          Visible         =   0   'False
  84.          Width           =   2055
  85.       End
  86.       Begin VB.Label lblNewgame 
  87.          Alignment       =   2  'Center
  88.          BackStyle       =   0  'Transparent
  89.          Caption         =   "New Game Press F2"
  90.          BeginProperty Font 
  91.             Name            =   "MS Sans Serif"
  92.             Size            =   13.5
  93.             Charset         =   0
  94.             Weight          =   400
  95.             Underline       =   0   'False
  96.             Italic          =   0   'False
  97.             Strikethrough   =   0   'False
  98.          EndProperty
  99.          ForeColor       =   &H00FFFFFF&
  100.          Height          =   855
  101.          Left            =   360
  102.          TabIndex        =   11
  103.          Top             =   840
  104.          Width           =   1815
  105.       End
  106.       Begin VB.Label lblGameover 
  107.          Alignment       =   2  'Center
  108.          BackStyle       =   0  'Transparent
  109.          Caption         =   "Game Over"
  110.          BeginProperty Font 
  111.             Name            =   "MS Sans Serif"
  112.             Size            =   13.5
  113.             Charset         =   0
  114.             Weight          =   400
  115.             Underline       =   0   'False
  116.             Italic          =   0   'False
  117.             Strikethrough   =   0   'False
  118.          EndProperty
  119.          ForeColor       =   &H0000FF00&
  120.          Height          =   495
  121.          Left            =   240
  122.          TabIndex        =   10
  123.          Top             =   1080
  124.          Visible         =   0   'False
  125.          Width           =   2055
  126.       End
  127.       Begin VB.Label lblNewgame2 
  128.          Alignment       =   2  'Center
  129.          BackStyle       =   0  'Transparent
  130.          Caption         =   "New Game Press F2"
  131.          BeginProperty Font 
  132.             Name            =   "MS Sans Serif"
  133.             Size            =   13.5
  134.             Charset         =   0
  135.             Weight          =   400
  136.             Underline       =   0   'False
  137.             Italic          =   0   'False
  138.             Strikethrough   =   0   'False
  139.          EndProperty
  140.          ForeColor       =   &H00000000&
  141.          Height          =   855
  142.          Left            =   345
  143.          TabIndex        =   13
  144.          Top             =   855
  145.          Width           =   1815
  146.       End
  147.    End
  148.    Begin VB.Label lblLines 
  149.       Alignment       =   1  'Right Justify
  150.       BackStyle       =   0  'Transparent
  151.       Caption         =   "0"
  152.       ForeColor       =   &H0000FF00&
  153.       Height          =   255
  154.       Left            =   2760
  155.       TabIndex        =   8
  156.       Top             =   3000
  157.       Width           =   1575
  158.    End
  159.    Begin VB.Label lblLevel 
  160.       Alignment       =   1  'Right Justify
  161.       BackStyle       =   0  'Transparent
  162.       Caption         =   "0"
  163.       ForeColor       =   &H0000FF00&
  164.       Height          =   255
  165.       Left            =   2760
  166.       TabIndex        =   7
  167.       Top             =   2400
  168.       Width           =   1575
  169.    End
  170.    Begin VB.Label Labels 
  171.       BackStyle       =   0  'Transparent
  172.       Caption         =   "Lines:"
  173.       ForeColor       =   &H0000FF00&
  174.       Height          =   255
  175.       Index           =   3
  176.       Left            =   2760
  177.       TabIndex        =   6
  178.       Top             =   2760
  179.       Width           =   1575
  180.    End
  181.    Begin VB.Label Labels 
  182.       BackStyle       =   0  'Transparent
  183.       Caption         =   "Level:"
  184.       ForeColor       =   &H0000FF00&
  185.       Height          =   255
  186.       Index           =   2
  187.       Left            =   2760
  188.       TabIndex        =   5
  189.       Top             =   2160
  190.       Width           =   1575
  191.    End
  192.    Begin VB.Label Labels 
  193.       BackStyle       =   0  'Transparent
  194.       Caption         =   "Next:"
  195.       ForeColor       =   &H0000FF00&
  196.       Height          =   255
  197.       Index           =   1
  198.       Left            =   2760
  199.       TabIndex        =   4
  200.       Top             =   240
  201.       Width           =   1575
  202.    End
  203.    Begin VB.Label lblScore 
  204.       Alignment       =   1  'Right Justify
  205.       BackStyle       =   0  'Transparent
  206.       Caption         =   "0"
  207.       ForeColor       =   &H0000FF00&
  208.       Height          =   255
  209.       Left            =   2760
  210.       TabIndex        =   3
  211.       Top             =   1800
  212.       Width           =   1575
  213.    End
  214.    Begin VB.Label Labels 
  215.       BackStyle       =   0  'Transparent
  216.       Caption         =   "Score:"
  217.       ForeColor       =   &H0000FF00&
  218.       Height          =   255
  219.       Index           =   0
  220.       Left            =   2760
  221.       TabIndex        =   2
  222.       Top             =   1560
  223.       Width           =   1575
  224.    End
  225.    Begin VB.Line Lines 
  226.       BorderColor     =   &H0000FF00&
  227.       BorderWidth     =   3
  228.       Index           =   4
  229.       X1              =   304
  230.       X2              =   304
  231.       Y1              =   367
  232.       Y2              =   8
  233.    End
  234.    Begin VB.Line Lines 
  235.       BorderColor     =   &H0000FF00&
  236.       BorderWidth     =   3
  237.       Index           =   3
  238.       X1              =   179
  239.       X2              =   179
  240.       Y1              =   367
  241.       Y2              =   6
  242.    End
  243.    Begin VB.Line Lines 
  244.       BorderColor     =   &H0000FF00&
  245.       BorderWidth     =   3
  246.       Index           =   2
  247.       X1              =   6
  248.       X2              =   6
  249.       Y1              =   367
  250.       Y2              =   6
  251.    End
  252.    Begin VB.Line Lines 
  253.       BorderColor     =   &H0000FF00&
  254.       BorderWidth     =   3
  255.       Index           =   1
  256.       X1              =   8
  257.       X2              =   304
  258.       Y1              =   6
  259.       Y2              =   6
  260.    End
  261.    Begin VB.Line Lines 
  262.       BorderColor     =   &H0000FF00&
  263.       BorderWidth     =   3
  264.       Index           =   0
  265.       X1              =   8
  266.       X2              =   304
  267.       Y1              =   367
  268.       Y2              =   367
  269.    End
  270.    Begin VB.Menu mnuGame 
  271.       Caption         =   "&Game"
  272.       Begin VB.Menu mnuNewGame 
  273.          Caption         =   "&New Game"
  274.          Shortcut        =   {F2}
  275.       End
  276.       Begin VB.Menu mnuPause 
  277.          Caption         =   "&Pause"
  278.          Shortcut        =   {F3}
  279.       End
  280.       Begin VB.Menu mnuLine3431 
  281.          Caption         =   "-"
  282.       End
  283.       Begin VB.Menu mnuHighscores 
  284.          Caption         =   "View Highscores"
  285.       End
  286.       Begin VB.Menu mnuLine3954 
  287.          Caption         =   "-"
  288.       End
  289.       Begin VB.Menu mnuQuit 
  290.          Caption         =   "&Quit"
  291.       End
  292.    End
  293.    Begin VB.Menu mnuHelp 
  294.       Caption         =   "&Help"
  295.       Begin VB.Menu mnuControls 
  296.          Caption         =   "&Controls"
  297.       End
  298.       Begin VB.Menu mnuAbout 
  299.          Caption         =   "&About"
  300.       End
  301.    End
  302. End
  303. Attribute VB_Name = "frmMain"
  304. Attribute VB_GlobalNameSpace = False
  305. Attribute VB_Creatable = False
  306. Attribute VB_PredeclaredId = True
  307. Attribute VB_Exposed = False
  308. Private Declare Function PlaySound Lib _
  309.     "winmm.dll" Alias "PlaySoundA" ( _
  310.     ByVal lpszName As String, _
  311.     ByVal hModule As Long, _
  312.     ByVal dwFlags As Long) As Long
  313.  
  314. Private Const SND_ASYNC& = &H1
  315. ' Play asynchronously
  316. Private Const SND_NODEFAULT& = &H2
  317. ' Silence if sound not found
  318. Private Const SND_RESOURCE& = &H40004
  319. ' Name is resource name or atom
  320.  
  321. Dim hInst As Long
  322. ' Handle to Application Instance
  323. Dim sSoundName As String
  324. ' String to hold sound resource name
  325. Dim lFlags As Long
  326. ' PlaySound() flags
  327. Dim lRet As Long
  328. ' Return value
  329.  
  330.  
  331.     Dim CountBlocks, CountTime As Long, CountLines As Integer, LinesErased(3) As Integer
  332. Dim LineAnimationColor As Integer
  333. Dim LineAnimation As Boolean
  334.  
  335. Dim PieceAnimation As Integer
  336. Dim CheatKeys As Integer
  337. Dim CheatActivated As Boolean
  338.  
  339.  
  340.  
  341. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  342. Private Declare Function GetTickCount Lib "kernel32" () As Long
  343.  
  344.  
  345. Dim Grid(9, -2 To 20) As Boolean
  346. Dim GridColor(9, -2 To 20) As Integer
  347. Dim Level As Integer
  348. Dim Speed(20) As Long 'speed of level
  349. Dim NextPiece As Integer
  350. Dim NextPieceGrid(3) As TetrisPiece
  351. Dim Score As Long
  352. Dim xLines As Integer
  353. Dim Paused As Boolean
  354. Dim ScoreDone As Boolean
  355.  
  356. Dim Gameover As Boolean 'Game Over
  357.  
  358.  
  359. Private Sub NewGame()
  360.     LineAnimation = False
  361.     ScoreDone = False
  362.     lblNewgame.Visible = False
  363.     lblNewgame2.Visible = False
  364.     lblGameover.Visible = False
  365.  
  366.     For a = 0 To 9
  367.         For B = -2 To 20
  368.             Grid(a, B) = False
  369.         Next B
  370.     Next a
  371.     
  372.     For a = 0 To 9
  373.         For B = 0 To 20
  374.             GridColor(a, B) = 0
  375.         Next B
  376.     Next a
  377.     
  378.     Level = 0
  379.     Score = 0
  380.     xLines = 0
  381.     Gameover = False
  382.     Paused = False
  383.     lblLevel.Caption = 0
  384.     UpdateStats
  385.     
  386.     Randomize
  387.     NextPiece = Int(Rnd * 7)
  388.     
  389.     GameLoop
  390. End Sub
  391.  
  392. Private Sub GameOver2()
  393.     
  394.     Dim msTime2 As Long
  395.     Gameover = True
  396.     
  397.     For a = 20 To 0 Step -1
  398.         msTime2 = 100 + GetTickCount
  399.         
  400.         For B = 0 To 9
  401.             GridColor(B, a) = 7
  402.         Next B
  403.         DrawGrid
  404.         
  405.         
  406.         sSoundName = "gameover"
  407.         lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  408.         If ScoreDone = False Then lRet = PlaySound(sSoundName, hInst, lFlags)
  409.             
  410.         Do
  411.             DoEvents
  412.         Loop While GetTickCount < msTime2
  413.     Next a
  414.         
  415.     lblGameover.Visible = True
  416.         
  417.     CurrentColor = 7
  418.     
  419.     
  420.     Dim HighScoreName As String
  421.     If ScoreDone = False And Score > Int(Val(ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score1"))) Then
  422.         ScoreDone = True
  423.         HighScoreName = InputBox$("You have achieved a high score. Please enter your name.", "High Score", "Anonymous")
  424.         
  425.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4")
  426.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4")
  427.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3")
  428.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3")
  429.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score2")
  430.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name2")
  431.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score2", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score1")
  432.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name2", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name1")
  433.         
  434.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score1", ValString, Score
  435.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name1", ValString, HighScoreName
  436.         frmHighscores.Show 1
  437.         Exit Sub
  438.         
  439.     ElseIf ScoreDone = False And Score > Int(Val(ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score2"))) Then
  440.         ScoreDone = True
  441.         HighScoreName = InputBox$("You have achieved a high score. Please enter your name.", "High Score", "Anonymous")
  442.         
  443.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4")
  444.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4")
  445.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3")
  446.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3")
  447.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score2")
  448.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name2")
  449.         
  450.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score2", ValString, Score
  451.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name2", ValString, HighScoreName
  452.         frmHighscores.Show 1
  453.         Exit Sub
  454.         
  455.     ElseIf ScoreDone = False And Score > Int(Val(ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3"))) Then
  456.         ScoreDone = True
  457.         HighScoreName = InputBox$("You have achieved a high score. Please enter your name.", "High Score", "Anonymous")
  458.         
  459.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4")
  460.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4")
  461.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3")
  462.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3")
  463.         
  464.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score3", ValString, Score
  465.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name3", ValString, HighScoreName
  466.         frmHighscores.Show 1
  467.         Exit Sub
  468.         
  469.     ElseIf ScoreDone = False And Score > Int(Val(ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4"))) Then
  470.         ScoreDone = True
  471.         HighScoreName = InputBox$("You have achieved a high score. Please enter your name.", "High Score", "Anonymous")
  472.         
  473.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4")
  474.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name5", ValString, ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4")
  475.         
  476.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score4", ValString, Score
  477.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name4", ValString, HighScoreName
  478.         frmHighscores.Show 1
  479.         Exit Sub
  480.         
  481.     ElseIf ScoreDone = False And Score > Int(Val(ReadRegistry(HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5"))) Then
  482.         ScoreDone = True
  483.         HighScoreName = InputBox$("You have achieved a high score. Please enter your name.", "High Score", "Anonymous")
  484.         
  485.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Score5", ValString, Score
  486.         WriteRegistry HKEY_LOCAL_MACHINE, "Software/Simplixx", "Name5", ValString, HighScoreName
  487.         frmHighscores.Show 1
  488.         Exit Sub
  489.     End If
  490.     
  491.     
  492.     
  493. End Sub
  494.  
  495. Private Sub CreatePiece()
  496.     If Grid(3, 0) = True Or Grid(4, 0) = True Or Grid(5, 0) = True Or Grid(6, 0) = True Then
  497.         GameOver2
  498.         Exit Sub
  499.     End If
  500.  
  501.     Randomize
  502.     PieceName = NextPiece
  503.     NextPiece = Int(Rnd * 7)
  504.     Direction = 0
  505.     
  506.     Dim CheatPiece As Integer
  507.     CheatPiece = Int(Rnd * 49)
  508.     If CheatPiece = 0 Then NextPiece = 8
  509.     
  510.     Select Case NextPiece
  511.         Case 0              '...OOOO...
  512.                             '..........
  513.             MakePiece(0).X = 3
  514.             MakePiece(0).Y = 0
  515.             MakePiece(1).X = 4
  516.             MakePiece(1).Y = 0
  517.             MakePiece(2).X = 5
  518.             MakePiece(2).Y = 0
  519.             MakePiece(3).X = 6
  520.             MakePiece(3).Y = 0
  521.             
  522.         Case 1              '...OO.....
  523.                             '....OO....
  524.             MakePiece(0).X = 3
  525.             MakePiece(0).Y = 0
  526.             MakePiece(1).X = 4
  527.             MakePiece(1).Y = 0
  528.             MakePiece(2).X = 4
  529.             MakePiece(2).Y = 1
  530.             MakePiece(3).X = 5
  531.             MakePiece(3).Y = 1
  532.             
  533.         Case 2              '....OO....
  534.                             '...OO.....
  535.             MakePiece(0).X = 3
  536.             MakePiece(0).Y = 1
  537.             MakePiece(1).X = 4
  538.             MakePiece(1).Y = 0
  539.             MakePiece(2).X = 4
  540.             MakePiece(2).Y = 1
  541.             MakePiece(3).X = 5
  542.             MakePiece(3).Y = 0
  543.             
  544.         Case 3              '....O.....
  545.                             '...OOO....
  546.             MakePiece(0).X = 3
  547.             MakePiece(0).Y = 1
  548.             MakePiece(1).X = 4
  549.             MakePiece(1).Y = 0
  550.             MakePiece(2).X = 4
  551.             MakePiece(2).Y = 1
  552.             MakePiece(3).X = 5
  553.             MakePiece(3).Y = 1
  554.             
  555.         Case 4              '...O......
  556.                             '...OOO....
  557.             MakePiece(0).X = 3
  558.             MakePiece(0).Y = 0
  559.             MakePiece(1).X = 3
  560.             MakePiece(1).Y = 1
  561.             MakePiece(2).X = 4
  562.             MakePiece(2).Y = 1
  563.             MakePiece(3).X = 5
  564.             MakePiece(3).Y = 1
  565.             
  566.         Case 5              '.....O....
  567.                             '...OOO....
  568.             MakePiece(0).X = 3
  569.             MakePiece(0).Y = 1
  570.             MakePiece(1).X = 4
  571.             MakePiece(1).Y = 1
  572.             MakePiece(2).X = 5
  573.             MakePiece(2).Y = 0
  574.             MakePiece(3).X = 5
  575.             MakePiece(3).Y = 1
  576.             
  577.         Case 6              '...OO.....
  578.                             '...OO.....
  579.             MakePiece(0).X = 3
  580.             MakePiece(0).Y = 0
  581.             MakePiece(1).X = 3
  582.             MakePiece(1).Y = 1
  583.             MakePiece(2).X = 4
  584.             MakePiece(2).Y = 0
  585.             MakePiece(3).X = 4
  586.             MakePiece(3).Y = 1
  587.             CurrentColor = 6
  588.             
  589.         Case 8
  590.             MakePiece(0).X = 3
  591.             MakePiece(0).Y = 0
  592.             MakePiece(1).X = 3
  593.             MakePiece(1).Y = 0
  594.             MakePiece(2).X = 3
  595.             MakePiece(2).Y = 0
  596.             MakePiece(3).X = 3
  597.             MakePiece(3).Y = 0
  598.             CurrentColor = 8
  599.     End Select
  600.     
  601.     For a = 0 To 3
  602.         NextPieceGrid(a).X = MakePiece(a).X
  603.         NextPieceGrid(a).Y = MakePiece(a).Y
  604.     Next a
  605.     
  606.     Select Case PieceName
  607.         Case 0              '...OOOO...
  608.                             '..........
  609.             MakePiece(0).X = 3
  610.             MakePiece(0).Y = 0
  611.             MakePiece(1).X = 4
  612.             MakePiece(1).Y = 0
  613.             MakePiece(2).X = 5
  614.             MakePiece(2).Y = 0
  615.             MakePiece(3).X = 6
  616.             MakePiece(3).Y = 0
  617.             CurrentColor = 0
  618.             
  619.         Case 1              '...OO.....
  620.                             '....OO....
  621.             MakePiece(0).X = 3
  622.             MakePiece(0).Y = 0
  623.             MakePiece(1).X = 4
  624.             MakePiece(1).Y = 0
  625.             MakePiece(2).X = 4
  626.             MakePiece(2).Y = 1
  627.             MakePiece(3).X = 5
  628.             MakePiece(3).Y = 1
  629.             CurrentColor = 1
  630.             
  631.         Case 2              '....OO....
  632.                             '...OO.....
  633.             MakePiece(0).X = 3
  634.             MakePiece(0).Y = 1
  635.             MakePiece(1).X = 4
  636.             MakePiece(1).Y = 0
  637.             MakePiece(2).X = 4
  638.             MakePiece(2).Y = 1
  639.             MakePiece(3).X = 5
  640.             MakePiece(3).Y = 0
  641.             CurrentColor = 2
  642.             
  643.         Case 3              '....O.....
  644.                             '...OOO....
  645.             MakePiece(0).X = 3
  646.             MakePiece(0).Y = 1
  647.             MakePiece(1).X = 4
  648.             MakePiece(1).Y = 0
  649.             MakePiece(2).X = 4
  650.             MakePiece(2).Y = 1
  651.             MakePiece(3).X = 5
  652.             MakePiece(3).Y = 1
  653.             CurrentColor = 3
  654.             
  655.         Case 4              '...O......
  656.                             '...OOO....
  657.             MakePiece(0).X = 3
  658.             MakePiece(0).Y = 0
  659.             MakePiece(1).X = 3
  660.             MakePiece(1).Y = 1
  661.             MakePiece(2).X = 4
  662.             MakePiece(2).Y = 1
  663.             MakePiece(3).X = 5
  664.             MakePiece(3).Y = 1
  665.             CurrentColor = 4
  666.             
  667.         Case 5              '.....O....
  668.                             '...OOO....
  669.             MakePiece(0).X = 3
  670.             MakePiece(0).Y = 1
  671.             MakePiece(1).X = 4
  672.             MakePiece(1).Y = 1
  673.             MakePiece(2).X = 5
  674.             MakePiece(2).Y = 0
  675.             MakePiece(3).X = 5
  676.             MakePiece(3).Y = 1
  677.             CurrentColor = 5
  678.             
  679.         Case 6              '...OO.....
  680.                             '...OO.....
  681.             MakePiece(0).X = 3
  682.             MakePiece(0).Y = 0
  683.             MakePiece(1).X = 3
  684.             MakePiece(1).Y = 1
  685.             MakePiece(2).X = 4
  686.             MakePiece(2).Y = 0
  687.             MakePiece(3).X = 4
  688.             MakePiece(3).Y = 1
  689.             CurrentColor = 6
  690.             
  691.         Case 8
  692.             MakePiece(0).X = 3
  693.             MakePiece(0).Y = 0
  694.             MakePiece(1).X = 3
  695.             MakePiece(1).Y = 0
  696.             MakePiece(2).X = 3
  697.             MakePiece(2).Y = 0
  698.             MakePiece(3).X = 3
  699.             MakePiece(3).Y = 0
  700.             CurrentColor = 8
  701.     End Select
  702.     
  703.     For a = 0 To 3
  704.         CurrentPiece(a).X = MakePiece(a).X
  705.         CurrentPiece(a).Y = MakePiece(a).Y
  706.     Next a
  707.     
  708.     picNext.Cls
  709.     For a = 0 To 3
  710.         BitBlt picNext.hDC, (NextPieceGrid(a).X - 3) * 17 + 5, NextPieceGrid(a).Y * 17, 17, 17, picBlocks.hDC, NextPiece * 17, 0, vbSrcCopy
  711.     Next a
  712. End Sub
  713.  
  714. Private Sub LevelUp()
  715.     
  716.     If Int(xLines / 10) < 21 Then Level = Int(xLines / 10)
  717.     
  718.     lblLevel.Caption = Level
  719. End Sub
  720.  
  721. Private Sub GameLoop()
  722.     If Paused = True Then GoTo PauseSkip
  723.     Dim msTime As Long
  724.     Speed(0) = 1000
  725.     Speed(1) = 900
  726.     Speed(2) = 850
  727.     Speed(3) = 800
  728.     Speed(4) = 700
  729.     Speed(5) = 650
  730.     Speed(6) = 500
  731.     Speed(7) = 450
  732.     Speed(8) = 400
  733.     Speed(9) = 400
  734.     Speed(10) = 350
  735.     Speed(11) = 350
  736.     Speed(12) = 300
  737.     Speed(13) = 310
  738.     Speed(14) = 300
  739.     Speed(15) = 270
  740.     Speed(16) = 130
  741.     Speed(17) = 100
  742.     Speed(18) = 70
  743.     Speed(19) = 50
  744.     Speed(20) = 20
  745.     
  746.     
  747.  
  748.     CreatePiece
  749.  
  750.     
  751.     DrawGrid
  752.     
  753. PauseSkip:
  754.     Do
  755.         Dim AppSpeed As Long
  756.         Dim ColorAnimation As Boolean
  757.         AppSpeed = Speed(Level)
  758.         If PieceName = 8 Then AppSpeed = Int(AppSpeed / 4)
  759.         msTime = AppSpeed + GetTickCount
  760.  
  761.         'Refresh grid
  762.         DrawGrid
  763.         
  764.         'Check lines for level
  765.         LevelUp
  766.         
  767.         Do While Paused = True
  768.             lblPaused.Visible = True
  769.                 DoEvents
  770.         Loop
  771.         lblPaused.Visible = False
  772.         
  773.         Do
  774.             DoEvents
  775.         Loop While GetTickCount < msTime
  776.         
  777.         
  778.         DropPiece 'Drop Piece
  779.         
  780.     Loop Until Gameover = True
  781. End Sub
  782.  
  783. Public Sub DrawGrid()
  784. '    If Gameover = True Then Exit Sub
  785.     picGrid.Cls
  786.     
  787.     If Gameover = False Then
  788.     For a = 0 To 3
  789.         BitBlt picGrid.hDC, CurrentPiece(a).X * 17, CurrentPiece(a).Y * 17, 17, 17, picBlocks.hDC, CurrentColor * 17, 0, vbSrcCopy
  790.     Next a
  791.     End If
  792.  
  793.     For a = 0 To 9
  794.         For B = 0 To 20
  795.             If Grid(a, B) Then
  796.                 BitBlt picGrid.hDC, a * 17, B * 17, 17, 17, picBlocks.hDC, GridColor(a, B) * 17, 0, vbSrcCopy
  797.             End If
  798.         Next B
  799.     Next a
  800. End Sub
  801.  
  802.  
  803.  
  804. Private Sub Form_Load()
  805.     MsgBox "COMPILE FIRST!!" & vbCrLf & "This version of Simplixx was released on pscode.com" & vbCrLf & "http://www.chaoticlogic.net/", vbOKOnly Or vbExclamation, "Simplixx"
  806.  
  807.     hInst = App.hInstance
  808.     Paused = True
  809.     Me.Show
  810.     
  811.     
  812.     'NewGame
  813.     
  814.     Intro
  815. End Sub
  816.  
  817. Private Sub Form_Unload(Cancel As Integer)
  818.     End
  819. End Sub
  820.  
  821. Private Sub Intro()
  822.     For a = 0 To 9
  823.         For B = 0 To 20
  824.             Grid(a, B) = 1
  825.             GridColor(a, B) = Int(Rnd * 6)
  826.         Next B
  827.     Next a
  828.     
  829.     DrawGrid
  830.     
  831.     For a = 0 To 9
  832.         For B = 0 To 20
  833.             Grid(a, B) = 0
  834.             GridColor(a, B) = 0
  835.         Next B
  836.     Next a
  837. End Sub
  838.  
  839. Private Sub UpdateStats()
  840.     lblScore.Caption = Score
  841.     lblLines.Caption = xLines
  842. End Sub
  843.  
  844. Private Sub EndDrop()
  845.     If Gameover = True Then Exit Sub
  846.     sSoundName = "drop"
  847.     lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  848.     lRet = PlaySound(sSoundName, hInst, lFlags)
  849.     
  850.     If PieceName = 8 Then
  851.         UpdateStats
  852.         GameLoop
  853.     End If
  854.  
  855.     For a = 0 To 3
  856.         Grid(CurrentPiece(a).X, CurrentPiece(a).Y) = True
  857.         GridColor(CurrentPiece(a).X, CurrentPiece(a).Y) = CurrentColor
  858.     Next a
  859.     
  860.     CountLines = 0
  861.     CountTime = 0
  862.     CountLines = 0
  863.     
  864.     For a = 0 To 20
  865.         CountBlocks = 0
  866.         
  867.         For B = 0 To 9
  868.             If Grid(B, a) = True Then CountBlocks = CountBlocks + 1
  869.         Next B
  870.         
  871.         If CountBlocks = 10 Then
  872.             CountLines = CountLines + 1
  873.             LinesErased(CountLines - 1) = a
  874.         End If
  875.     Next a
  876.     
  877.     xLines = xLines + CountLines
  878.     
  879.     Select Case CountLines
  880.         Case 1
  881.             Score = Score + 300
  882.             sSoundName = "line"
  883.             lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  884.             lRet = PlaySound(sSoundName, hInst, lFlags)
  885.         Case 2
  886.             Score = Score + 600
  887.             sSoundName = "line"
  888.             lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  889.             lRet = PlaySound(sSoundName, hInst, lFlags)
  890.         Case 3
  891.             Score = Score + 1200
  892.             sSoundName = "line"
  893.             lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  894.             lRet = PlaySound(sSoundName, hInst, lFlags)
  895.         Case 4
  896.             Score = Score + 2500
  897.             sSoundName = "tetris"
  898.             lFlags = SND_RESOURCE + SND_ASYNC + SND_NODEFAULT
  899.             lRet = PlaySound(sSoundName, hInst, lFlags)
  900.     End Select
  901.     
  902.     'Remove Pieces
  903.     
  904.     If CountLines > 0 Then
  905.         LineAnimationColor = 10
  906.         For a = 0 To CountLines - 1
  907.             For B = 0 To 9
  908.                 GridColor(B, LinesErased(a)) = LineAnimationColor
  909.             Next B
  910.         Next a
  911.     
  912.         DrawGrid
  913.         LineAnimation = True
  914.         
  915.         Dim RemoveTime As Long
  916.         RemoveTime = 500 + GetTickCount
  917.         Do
  918.             DoEvents
  919.         Loop While GetTickCount < RemoveTime
  920.         
  921.         LineAnimation = False
  922.     
  923.         For a = 0 To CountLines - 1
  924.             For B = 0 To 9
  925.                 Grid(B, LinesErased(a)) = False
  926.                 GridColor(B, LinesErased(a)) = 0
  927.             Next B
  928.             
  929.             For B = 0 To 9
  930.                 For c = LinesErased(a) To 1 Step -1
  931.                     Grid(B, c) = Grid(B, c - 1)
  932.                     GridColor(B, c) = GridColor(B, c - 1)
  933.                 Next c
  934.             Next B
  935.         Next a
  936.     End If
  937.     
  938.     UpdateStats
  939.     
  940.     GameLoop
  941. End Sub
  942.  
  943. Private Sub PowerDrop()
  944.     If PieceName = 8 Then
  945.         For a = CurrentPiece(0).Y To 20
  946.             Grid(CurrentPiece(0).X, a) = False
  947.             DrawGrid
  948.         Next a
  949.         
  950.         Score = Score + Abs(20 - CurrentPiece(0).Y) * 50
  951.         EndDrop
  952.         Exit Sub
  953.     End If
  954.  
  955.     For a = 0 To 3
  956.         If CurrentPiece(a).Y + 1 = 21 Then
  957.             EndDrop
  958.             Exit Sub
  959.         ElseIf Grid(CurrentPiece(a).X, CurrentPiece(a).Y + 1) = True Then
  960.             EndDrop
  961.             Exit Sub
  962.         End If
  963.     Next a
  964.     
  965.     Dim DropLines As Integer
  966.     DropLines = 0
  967.     
  968.     Do
  969.         DropLines = DropLines + 1
  970.         For a = 0 To 3
  971.             CurrentPiece(a).Y = CurrentPiece(a).Y + 1
  972.         Next a
  973.         
  974.         For a = 0 To 3
  975.             If CurrentPiece(a).Y + 1 = 21 Then
  976.                 GoTo CountLines
  977.             ElseIf Grid(CurrentPiece(a).X, CurrentPiece(a).Y + 1) = True Then
  978.                 GoTo CountLines
  979.             End If
  980.         Next a
  981.     Loop
  982.     
  983. CountLines:
  984.     Score = Score + (DropLines * 5)
  985.     UpdateStats
  986.     EndDrop
  987. End Sub
  988.  
  989. Private Sub DropPiece()
  990.     If PieceName = 8 Then
  991.         If CurrentPiece(0).Y + 1 = 21 Then
  992.             EndDrop
  993.             Exit Sub
  994.         ElseIf Grid(CurrentPiece(0).X, CurrentPiece(1).Y + 1) = True Then
  995.             Grid(CurrentPiece(0).X, CurrentPiece(1).Y + 1) = False
  996.             Score = Score + 100
  997.             UpdateStats
  998.         End If
  999.         For a = 0 To 3
  1000.             CurrentPiece(a).Y = CurrentPiece(a).Y + 1
  1001.         Next a
  1002.         DrawGrid
  1003.         Exit Sub
  1004.     End If
  1005.  
  1006.     For a = 0 To 3
  1007.         If CurrentPiece(a).Y + 1 = 21 Then
  1008.             EndDrop
  1009.             Exit Sub
  1010.         ElseIf Grid(CurrentPiece(a).X, CurrentPiece(a).Y + 1) = True Then
  1011.             EndDrop
  1012.             Exit Sub
  1013.         End If
  1014.     Next a
  1015.     
  1016.     For a = 0 To 3
  1017.         CurrentPiece(a).Y = CurrentPiece(a).Y + 1
  1018.     Next a
  1019.     
  1020.     DrawGrid
  1021.     
  1022. End Sub
  1023.  
  1024. Private Sub MoveLeft()
  1025.     If PieceName = 8 Then
  1026.         If CurrentPiece(0).X - 1 = -1 Then
  1027.             Exit Sub
  1028.         ElseIf Grid(CurrentPiece(0).X - 1, CurrentPiece(0).Y) = True Then
  1029.             Score = Score + 100
  1030.             UpdateStats
  1031.             Grid(CurrentPiece(0).X - 1, CurrentPiece(0).Y) = False
  1032.         End If
  1033.         For a = 0 To 3
  1034.             CurrentPiece(a).X = CurrentPiece(a).X - 1
  1035.         Next a
  1036.         DrawGrid
  1037.         Exit Sub
  1038.     End If
  1039.  
  1040.     For a = 0 To 3
  1041.         If CurrentPiece(a).X - 1 = -1 Then
  1042.             Exit Sub
  1043.         ElseIf Grid(CurrentPiece(a).X - 1, CurrentPiece(a).Y) = True Then
  1044.             Exit Sub
  1045.         End If
  1046.     Next a
  1047.  
  1048.     For a = 0 To 3
  1049.         CurrentPiece(a).X = CurrentPiece(a).X - 1
  1050.     Next a
  1051.     
  1052.     DrawGrid
  1053.     
  1054. End Sub
  1055.  
  1056. Private Sub MoveRight()
  1057.     If PieceName = 8 Then
  1058.         If CurrentPiece(0).X + 1 = 10 Then
  1059.             Exit Sub
  1060.         ElseIf Grid(CurrentPiece(0).X + 1, CurrentPiece(0).Y) = True Then
  1061.             Score = Score + 100
  1062.             UpdateStats
  1063.         
  1064.             Grid(CurrentPiece(0).X + 1, CurrentPiece(0).Y) = False
  1065.         End If
  1066.         For a = 0 To 3
  1067.             CurrentPiece(a).X = CurrentPiece(a).X + 1
  1068.         Next a
  1069.         DrawGrid
  1070.         Exit Sub
  1071.     End If
  1072.     
  1073.     For a = 0 To 3
  1074.         If CurrentPiece(a).X + 1 = 10 Then
  1075.             Exit Sub
  1076.         ElseIf Grid(CurrentPiece(a).X + 1, CurrentPiece(a).Y) = True Then
  1077.             Exit Sub
  1078.         End If
  1079.     Next a
  1080.  
  1081.     For a = 0 To 3
  1082.         CurrentPiece(a).X = CurrentPiece(a).X + 1
  1083.     Next a
  1084.     
  1085.     DrawGrid
  1086.     
  1087. End Sub
  1088.  
  1089. Private Sub RotatePiece()
  1090.     Dim RotSource As TetrisPiece
  1091.     Select Case PieceName
  1092.         Case 0              '...OOOO...
  1093.                             '..........
  1094.             Select Case Direction
  1095.                 Case 0
  1096.                     RotSource.X = CurrentPiece(0).X + 1
  1097.                     RotSource.Y = CurrentPiece(0).Y - 1
  1098.                     
  1099.                     'Check piece
  1100.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1101.                     If RotSource.Y + 2 > 20 Then Exit Sub
  1102.                     If Grid(RotSource.X + 1, RotSource.Y) = False And _
  1103.                       Grid(RotSource.X + 1, RotSource.Y + 1) = False And _
  1104.                       Grid(RotSource.X + 1, RotSource.Y + 2) = False And _
  1105.                       Grid(RotSource.X + 1, RotSource.Y + 3) = False Then
  1106.                         'Rotate Piece
  1107.                         Direction = Direction + 1
  1108.                         CurrentPiece(0).X = RotSource.X + 1
  1109.                         CurrentPiece(0).Y = RotSource.Y - 1 + 1
  1110.                         CurrentPiece(1).X = RotSource.X + 1
  1111.                         CurrentPiece(1).Y = RotSource.Y + 1
  1112.                         CurrentPiece(2).X = RotSource.X + 1
  1113.                         CurrentPiece(2).Y = RotSource.Y + 1 + 1
  1114.                         CurrentPiece(3).X = RotSource.X + 1
  1115.                         CurrentPiece(3).Y = RotSource.Y + 2 + 1
  1116.                         
  1117.                         'Refresh
  1118.                         DrawGrid
  1119.                         Exit Sub
  1120.                     End If
  1121.                 Case 1
  1122.                     RotSource.X = CurrentPiece(0).X - 1
  1123.                     RotSource.Y = CurrentPiece(0).Y + 1
  1124.                     
  1125.                     'Check piece
  1126.                     If RotSource.X - 1 < 0 Then Exit Sub
  1127.                     If RotSource.X + 2 > 9 Then Exit Sub
  1128.                     If RotSource.X + 1 > 9 Then Exit Sub
  1129.                     If Grid(RotSource.X - 1, RotSource.Y) = False And _
  1130.                       Grid(RotSource.X, RotSource.Y) = False And _
  1131.                       Grid(RotSource.X + 1, RotSource.Y) = False And _
  1132.                       Grid(RotSource.X + 2, RotSource.Y) = False Then
  1133.                         'Rotate Piece
  1134.                         Direction = 0
  1135.                         CurrentPiece(0).X = RotSource.X - 1
  1136.                         CurrentPiece(0).Y = RotSource.Y - 1 + 1
  1137.                         CurrentPiece(1).X = RotSource.X
  1138.                         CurrentPiece(1).Y = RotSource.Y - 1 + 1
  1139.                         CurrentPiece(2).X = RotSource.X + 1
  1140.                         CurrentPiece(2).Y = RotSource.Y - 1 + 1
  1141.                         CurrentPiece(3).X = RotSource.X + 2
  1142.                         CurrentPiece(3).Y = RotSource.Y - 1 + 1
  1143.                         
  1144.                         'Refresh
  1145.                         DrawGrid
  1146.                         Exit Sub
  1147.                     End If
  1148.             End Select
  1149.             
  1150.         Case 1              '...OO.....
  1151.                             '....OO....
  1152.             Select Case Direction
  1153.                 Case 0
  1154.                     RotSource.X = CurrentPiece(0).X + 1
  1155.                     RotSource.Y = CurrentPiece(0).Y + 1
  1156.                     
  1157.                     'Check piece
  1158.                     If RotSource.X + 1 > 9 Then Exit Sub
  1159.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1160.                     If Grid(RotSource.X + 1, RotSource.Y - 1) = False And _
  1161.                       Grid(RotSource.X + 1, RotSource.Y) = False And _
  1162.                       Grid(RotSource.X, RotSource.Y) = False And _
  1163.                       Grid(RotSource.X, RotSource.Y + 1) = False Then
  1164.                         'Rotate Piece
  1165.                         Direction = Direction + 1
  1166.                         CurrentPiece(0).X = RotSource.X + 1
  1167.                         CurrentPiece(0).Y = RotSource.Y - 1
  1168.                         CurrentPiece(1).X = RotSource.X + 1
  1169.                         CurrentPiece(1).Y = RotSource.Y
  1170.                         CurrentPiece(2).X = RotSource.X
  1171.                         CurrentPiece(2).Y = RotSource.Y
  1172.                         CurrentPiece(3).X = RotSource.X
  1173.                         CurrentPiece(3).Y = RotSource.Y + 1
  1174.                         
  1175.                         'Refresh
  1176.                         DrawGrid
  1177.                         Exit Sub
  1178.                     End If
  1179.                 Case 1
  1180.                     RotSource.X = CurrentPiece(0).X - 1
  1181.                     RotSource.Y = CurrentPiece(0).Y + 1
  1182.                     
  1183.                     'Check piece
  1184.                     If RotSource.X - 1 < 0 Then Exit Sub
  1185.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1186.                     If Grid(RotSource.X - 1, RotSource.Y - 1) = False And _
  1187.                       Grid(RotSource.X, RotSource.Y - 1) = False And _
  1188.                       Grid(RotSource.X, RotSource.Y) = False And _
  1189.                       Grid(RotSource.X + 1, RotSource.Y) = False Then
  1190.                         'Rotate Piece
  1191.                         Direction = 0
  1192.                         CurrentPiece(0).X = RotSource.X - 1
  1193.                         CurrentPiece(0).Y = RotSource.Y - 1
  1194.                         CurrentPiece(1).X = RotSource.X
  1195.                         CurrentPiece(1).Y = RotSource.Y - 1
  1196.                         CurrentPiece(2).X = RotSource.X
  1197.                         CurrentPiece(2).Y = RotSource.Y
  1198.                         CurrentPiece(3).X = RotSource.X + 1
  1199.                         CurrentPiece(3).Y = RotSource.Y
  1200.                         
  1201.                         'Refresh
  1202.                         DrawGrid
  1203.                         Exit Sub
  1204.                     End If
  1205.                     
  1206.             End Select
  1207.         Case 2              '....OO....
  1208.                             '...OO.....
  1209.             Select Case Direction
  1210.                 Case 0
  1211.                     RotSource.X = CurrentPiece(0).X + 1
  1212.                     RotSource.Y = CurrentPiece(0).Y
  1213.             
  1214.                     'Check piece
  1215.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1216.                     If Grid(RotSource.X, RotSource.Y - 1) = False And _
  1217.                       Grid(RotSource.X, RotSource.Y) = False And _
  1218.                       Grid(RotSource.X + 1, RotSource.Y) = False And _
  1219.                       Grid(RotSource.X + 1, RotSource.Y + 1) = False Then
  1220.                         'Rotate piece
  1221.                         Direction = Direction + 1
  1222.                         CurrentPiece(0).X = RotSource.X
  1223.                         CurrentPiece(0).Y = RotSource.Y - 1
  1224.                         CurrentPiece(1).X = RotSource.X
  1225.                         CurrentPiece(1).Y = RotSource.Y
  1226.                         CurrentPiece(2).X = RotSource.X + 1
  1227.                         CurrentPiece(2).Y = RotSource.Y
  1228.                         CurrentPiece(3).X = RotSource.X + 1
  1229.                         CurrentPiece(3).Y = RotSource.Y + 1
  1230.                         
  1231.                         'Refresh
  1232.                         DrawGrid
  1233.                         Exit Sub
  1234.                     End If
  1235.                 Case 1
  1236.                     RotSource.X = CurrentPiece(0).X
  1237.                     RotSource.Y = CurrentPiece(0).Y + 1
  1238.             
  1239.                     'Check piece
  1240.                     If RotSource.X - 1 < 0 Then Exit Sub
  1241.                     If Grid(RotSource.X - 1, RotSource.Y) = False And _
  1242.                       Grid(RotSource.X, RotSource.Y) = False And _
  1243.                       Grid(RotSource.X, RotSource.Y - 1) = False And _
  1244.                       Grid(RotSource.X + 1, RotSource.Y - 1) = False Then
  1245.                         'Rotate piece
  1246.                         Direction = 0
  1247.                         CurrentPiece(0).X = RotSource.X - 1
  1248.                         CurrentPiece(0).Y = RotSource.Y
  1249.                         CurrentPiece(1).X = RotSource.X
  1250.                         CurrentPiece(1).Y = RotSource.Y
  1251.                         CurrentPiece(2).X = RotSource.X
  1252.                         CurrentPiece(2).Y = RotSource.Y - 1
  1253.                         CurrentPiece(3).X = RotSource.X + 1
  1254.                         CurrentPiece(3).Y = RotSource.Y - 1
  1255.                         
  1256.                         'Refresh
  1257.                         DrawGrid
  1258.                         Exit Sub
  1259.                     End If
  1260.             End Select
  1261.         Case 3              '....O.....
  1262.                             '...OOO....
  1263.             Select Case Direction
  1264.                 Case 0
  1265.                     RotSource.X = CurrentPiece(2).X
  1266.                     RotSource.Y = CurrentPiece(2).Y
  1267.             
  1268.                     'Check piece
  1269.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1270.                     If Grid(RotSource.X, RotSource.Y + 1) = False Then
  1271.                         'Rotate piece
  1272.                         Direction = Direction + 1
  1273.                         CurrentPiece(0).X = RotSource.X
  1274.                         CurrentPiece(0).Y = RotSource.Y - 1
  1275.                         CurrentPiece(1).X = RotSource.X + 1
  1276.                         CurrentPiece(1).Y = RotSource.Y
  1277.                         CurrentPiece(2).X = RotSource.X
  1278.                         CurrentPiece(2).Y = RotSource.Y
  1279.                         CurrentPiece(3).X = RotSource.X
  1280.                         CurrentPiece(3).Y = RotSource.Y + 1
  1281.                         
  1282.                         'Refresh
  1283.                         DrawGrid
  1284.                         Exit Sub
  1285.                     End If
  1286.                 Case 1
  1287.                     RotSource.X = CurrentPiece(2).X
  1288.                     RotSource.Y = CurrentPiece(2).Y
  1289.             
  1290.                     'Check piece
  1291.                     If RotSource.X - 1 < 0 Then Exit Sub
  1292.                     If Grid(RotSource.X - 1, RotSource.Y) = False Then
  1293.                         'Rotate piece
  1294.                         Direction = Direction + 1
  1295.                         CurrentPiece(0).X = RotSource.X + 1
  1296.                         CurrentPiece(0).Y = RotSource.Y
  1297.                         CurrentPiece(1).X = RotSource.X
  1298.                         CurrentPiece(1).Y = RotSource.Y + 1
  1299.                         CurrentPiece(2).X = RotSource.X
  1300.                         CurrentPiece(2).Y = RotSource.Y
  1301.                         CurrentPiece(3).X = RotSource.X - 1
  1302.                         CurrentPiece(3).Y = RotSource.Y
  1303.                         
  1304.                         'Refresh
  1305.                         DrawGrid
  1306.                         Exit Sub
  1307.                     End If
  1308.                 Case 2
  1309.                     RotSource.X = CurrentPiece(2).X
  1310.                     RotSource.Y = CurrentPiece(2).Y
  1311.             
  1312.                     'Check piece
  1313.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1314.                     If Grid(RotSource.X, RotSource.Y + 1) = False Then
  1315.                         'Rotate piece
  1316.                         Direction = Direction + 1
  1317.                         CurrentPiece(0).X = RotSource.X
  1318.                         CurrentPiece(0).Y = RotSource.Y - 1
  1319.                         CurrentPiece(1).X = RotSource.X - 1
  1320.                         CurrentPiece(1).Y = RotSource.Y
  1321.                         CurrentPiece(2).X = RotSource.X
  1322.                         CurrentPiece(2).Y = RotSource.Y
  1323.                         CurrentPiece(3).X = RotSource.X
  1324.                         CurrentPiece(3).Y = RotSource.Y + 1
  1325.                         
  1326.                         'Refresh
  1327.                         DrawGrid
  1328.                         Exit Sub
  1329.                     End If
  1330.                 Case 3
  1331.                     RotSource.X = CurrentPiece(2).X
  1332.                     RotSource.Y = CurrentPiece(2).Y
  1333.             
  1334.                     'Check piece
  1335.                     If RotSource.X + 1 > 9 Then Exit Sub
  1336.                     If Grid(RotSource.X + 1, RotSource.Y) = False Then
  1337.                         'Rotate piece
  1338.                         Direction = 0
  1339.                         CurrentPiece(0).X = RotSource.X + 1
  1340.                         CurrentPiece(0).Y = RotSource.Y
  1341.                         CurrentPiece(1).X = RotSource.X
  1342.                         CurrentPiece(1).Y = RotSource.Y - 1
  1343.                         CurrentPiece(2).X = RotSource.X
  1344.                         CurrentPiece(2).Y = RotSource.Y
  1345.                         CurrentPiece(3).X = RotSource.X - 1
  1346.                         CurrentPiece(3).Y = RotSource.Y
  1347.                         
  1348.                         'Refresh
  1349.                         DrawGrid
  1350.                         Exit Sub
  1351.                     End If
  1352.             End Select
  1353.         Case 4              '...O......
  1354.                             '...OOO....
  1355.             Select Case Direction
  1356.                 Case 0
  1357.                     RotSource.X = CurrentPiece(0).X + 1
  1358.                     RotSource.Y = CurrentPiece(0).Y + 1
  1359.             
  1360.                     'Check piece
  1361.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1362.                     If Grid(RotSource.X, RotSource.Y - 1) = False And _
  1363.                       Grid(RotSource.X + 1, RotSource.Y - 1) = False And _
  1364.                       Grid(RotSource.X, RotSource.Y) = False And _
  1365.                       Grid(RotSource.X, RotSource.Y + 1) = False Then
  1366.                         'Rotate piece
  1367.                         Direction = Direction + 1
  1368.                         CurrentPiece(0).X = RotSource.X
  1369.                         CurrentPiece(0).Y = RotSource.Y - 1
  1370.                         CurrentPiece(1).X = RotSource.X + 1
  1371.                         CurrentPiece(1).Y = RotSource.Y - 1
  1372.                         CurrentPiece(2).X = RotSource.X
  1373.                         CurrentPiece(2).Y = RotSource.Y
  1374.                         CurrentPiece(3).X = RotSource.X
  1375.                         CurrentPiece(3).Y = RotSource.Y + 1
  1376.                         
  1377.                         'Refresh
  1378.                         DrawGrid
  1379.                         Exit Sub
  1380.                     End If
  1381.                 Case 1
  1382.                     RotSource.X = CurrentPiece(0).X
  1383.                     RotSource.Y = CurrentPiece(0).Y + 1
  1384.             
  1385.                     'Check piece
  1386.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1387.                     If RotSource.X - 1 < 0 Then Exit Sub
  1388.                     If Grid(RotSource.X - 1, RotSource.Y) = False And _
  1389.                       Grid(RotSource.X, RotSource.Y) = False And _
  1390.                       Grid(RotSource.X + 1, RotSource.Y) = False And _
  1391.                       Grid(RotSource.X + 1, RotSource.Y + 1) = False Then
  1392.                         'Rotate piece
  1393.                         Direction = Direction + 1
  1394.                         CurrentPiece(0).X = RotSource.X - 1
  1395.                         CurrentPiece(0).Y = RotSource.Y
  1396.                         CurrentPiece(1).X = RotSource.X
  1397.                         CurrentPiece(1).Y = RotSource.Y
  1398.                         CurrentPiece(2).X = RotSource.X + 1
  1399.                         CurrentPiece(2).Y = RotSource.Y
  1400.                         CurrentPiece(3).X = RotSource.X + 1
  1401.                         CurrentPiece(3).Y = RotSource.Y + 1
  1402.                         
  1403.                         'Refresh
  1404.                         DrawGrid
  1405.                         Exit Sub
  1406.                     End If
  1407.                 Case 2
  1408.                     RotSource.X = CurrentPiece(0).X + 1
  1409.                     RotSource.Y = CurrentPiece(0).Y
  1410.             
  1411.                     'Check piece
  1412.                     'If RotSource.Y + 1 > 20 Then Exit Sub
  1413.                     If Grid(RotSource.X - 1, RotSource.Y + 1) = False And _
  1414.                       Grid(RotSource.X, RotSource.Y + 1) = False And _
  1415.                       Grid(RotSource.X, RotSource.Y) = False And _
  1416.                       Grid(RotSource.X, RotSource.Y - 1) = False Then
  1417.                         'Rotate piece
  1418.                         Direction = Direction + 1
  1419.                         CurrentPiece(0).X = RotSource.X - 1
  1420.                         CurrentPiece(0).Y = RotSource.Y + 1
  1421.                         CurrentPiece(1).X = RotSource.X
  1422.                         CurrentPiece(1).Y = RotSource.Y + 1
  1423.                         CurrentPiece(2).X = RotSource.X
  1424.                         CurrentPiece(2).Y = RotSource.Y
  1425.                         CurrentPiece(3).X = RotSource.X
  1426.                         CurrentPiece(3).Y = RotSource.Y - 1
  1427.                         
  1428.                         'Refresh
  1429.                         DrawGrid
  1430.                         Exit Sub
  1431.                     End If
  1432.                 Case 3
  1433.                     RotSource.X = CurrentPiece(0).X + 1
  1434.                     RotSource.Y = CurrentPiece(0).Y - 1
  1435.             
  1436.                     'Check piece
  1437.                     If RotSource.X + 1 > 9 Then Exit Sub
  1438.                     If Grid(RotSource.X - 1, RotSource.Y - 1) = False And _
  1439.                       Grid(RotSource.X - 1, RotSource.Y) = False And _
  1440.                       Grid(RotSource.X, RotSource.Y) = False And _
  1441.                       Grid(RotSource.X + 1, RotSource.Y) = False Then
  1442.                         'Rotate piece
  1443.                         Direction = 0
  1444.                         CurrentPiece(0).X = RotSource.X - 1
  1445.                         CurrentPiece(0).Y = RotSource.Y - 1
  1446.                         CurrentPiece(1).X = RotSource.X - 1
  1447.                         CurrentPiece(1).Y = RotSource.Y
  1448.                         CurrentPiece(2).X = RotSource.X
  1449.                         CurrentPiece(2).Y = RotSource.Y
  1450.                         CurrentPiece(3).X = RotSource.X + 1
  1451.                         CurrentPiece(3).Y = RotSource.Y
  1452.                         
  1453.                         'Refresh
  1454.                         DrawGrid
  1455.                         Exit Sub
  1456.                     End If
  1457.             End Select
  1458.         Case 5              '.....O....
  1459.                             '...OOO....
  1460.             Select Case Direction
  1461.                 Case 0
  1462.                     RotSource.X = CurrentPiece(1).X
  1463.                     RotSource.Y = CurrentPiece(1).Y
  1464.             
  1465.                     'Check piece
  1466.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1467.                     If Grid(RotSource.X, RotSource.Y - 1) = False And _
  1468.                       Grid(RotSource.X, RotSource.Y) = False And _
  1469.                       Grid(RotSource.X, RotSource.Y + 1) = False And _
  1470.                       Grid(RotSource.X + 1, RotSource.Y + 1) = False Then
  1471.                         'Rotate piece
  1472.                         Direction = Direction + 1
  1473.                         CurrentPiece(0).X = RotSource.X
  1474.                         CurrentPiece(0).Y = RotSource.Y - 1
  1475.                         CurrentPiece(1).X = RotSource.X
  1476.                         CurrentPiece(1).Y = RotSource.Y
  1477.                         CurrentPiece(2).X = RotSource.X
  1478.                         CurrentPiece(2).Y = RotSource.Y + 1
  1479.                         CurrentPiece(3).X = RotSource.X + 1
  1480.                         CurrentPiece(3).Y = RotSource.Y + 1
  1481.                         
  1482.                         'Refresh
  1483.                         DrawGrid
  1484.                         Exit Sub
  1485.                     End If
  1486.                 Case 1
  1487.                     RotSource.X = CurrentPiece(1).X
  1488.                     RotSource.Y = CurrentPiece(1).Y
  1489.             
  1490.                     'Check piece
  1491.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1492.                     If RotSource.X - 1 < 0 Then Exit Sub
  1493.                     If Grid(RotSource.X + 1, RotSource.Y) = False And _
  1494.                       Grid(RotSource.X, RotSource.Y) = False And _
  1495.                       Grid(RotSource.X - 1, RotSource.Y) = False And _
  1496.                       Grid(RotSource.X - 1, RotSource.Y + 1) = False Then
  1497.                         'Rotate piece
  1498.                         Direction = Direction + 1
  1499.                         CurrentPiece(0).X = RotSource.X + 1
  1500.                         CurrentPiece(0).Y = RotSource.Y
  1501.                         CurrentPiece(1).X = RotSource.X
  1502.                         CurrentPiece(1).Y = RotSource.Y
  1503.                         CurrentPiece(2).X = RotSource.X - 1
  1504.                         CurrentPiece(2).Y = RotSource.Y
  1505.                         CurrentPiece(3).X = RotSource.X - 1
  1506.                         CurrentPiece(3).Y = RotSource.Y + 1
  1507.                         
  1508.                         'Refresh
  1509.                         DrawGrid
  1510.                         Exit Sub
  1511.                     End If
  1512.                 Case 2
  1513.                     RotSource.X = CurrentPiece(1).X
  1514.                     RotSource.Y = CurrentPiece(1).Y
  1515.             
  1516.                     'Check piece
  1517.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1518.                     If Grid(RotSource.X, RotSource.Y + 1) = False And _
  1519.                       Grid(RotSource.X, RotSource.Y) = False And _
  1520.                       Grid(RotSource.X, RotSource.Y - 1) = False And _
  1521.                       Grid(RotSource.X - 1, RotSource.Y - 1) = False Then
  1522.                         'Rotate piece
  1523.                         Direction = Direction + 1
  1524.                         CurrentPiece(0).X = RotSource.X
  1525.                         CurrentPiece(0).Y = RotSource.Y + 1
  1526.                         CurrentPiece(1).X = RotSource.X
  1527.                         CurrentPiece(1).Y = RotSource.Y
  1528.                         CurrentPiece(2).X = RotSource.X
  1529.                         CurrentPiece(2).Y = RotSource.Y - 1
  1530.                         CurrentPiece(3).X = RotSource.X - 1
  1531.                         CurrentPiece(3).Y = RotSource.Y - 1
  1532.                         
  1533.                         'Refresh
  1534.                         DrawGrid
  1535.                         Exit Sub
  1536.                     End If
  1537.                 Case 3
  1538.                     RotSource.X = CurrentPiece(1).X
  1539.                     RotSource.Y = CurrentPiece(1).Y
  1540.             
  1541.                     'Check piece
  1542.                     If RotSource.Y + 1 > 20 Then Exit Sub
  1543.                     If RotSource.X + 1 > 9 Then Exit Sub
  1544.                     If Grid(RotSource.X - 1, RotSource.Y) = False And _
  1545.                       Grid(RotSource.X, RotSource.Y) = False And _
  1546.                       Grid(RotSource.X + 1, RotSource.Y) = False And _
  1547.                       Grid(RotSource.X + 1, RotSource.Y - 1) = False Then
  1548.                         'Rotate piece
  1549.                         Direction = 0
  1550.                         CurrentPiece(0).X = RotSource.X - 1
  1551.                         CurrentPiece(0).Y = RotSource.Y
  1552.                         CurrentPiece(1).X = RotSource.X
  1553.                         CurrentPiece(1).Y = RotSource.Y
  1554.                         CurrentPiece(2).X = RotSource.X + 1
  1555.                         CurrentPiece(2).Y = RotSource.Y
  1556.                         CurrentPiece(3).X = RotSource.X + 1
  1557.                         CurrentPiece(3).Y = RotSource.Y - 1
  1558.                         
  1559.                         'Refresh
  1560.                         DrawGrid
  1561.                         Exit Sub
  1562.                     End If
  1563.             End Select
  1564.     End Select
  1565. End Sub
  1566.  
  1567.  
  1568. Private Sub lblLines_Click()
  1569.  
  1570. End Sub
  1571.  
  1572. Private Sub mnuAbout_Click()
  1573.     frmAbout.Show 1
  1574. End Sub
  1575.  
  1576. Private Sub mnuControls_Click()
  1577.     frmControls.Show 1
  1578. End Sub
  1579.  
  1580. Private Sub mnuHighscores_Click()
  1581.     frmHighscores.Show 1
  1582. End Sub
  1583.  
  1584. Private Sub mnuNewGame_Click()
  1585.     NewGame
  1586. End Sub
  1587.  
  1588. Private Sub mnuPause_Click()
  1589.     If Gameover = True Then Exit Sub
  1590.     
  1591.     If Paused = True Then
  1592.         Paused = False
  1593.         Exit Sub
  1594.     Else
  1595.         Paused = True
  1596.         GameLoop
  1597.         Exit Sub
  1598.     End If
  1599. End Sub
  1600.  
  1601. Private Sub mnuQuit_Click()
  1602.     Unload Me
  1603.     End
  1604. End Sub
  1605.  
  1606. Private Sub picGrid_KeyDown(KeyCode As Integer, Shift As Integer)
  1607.     If LineAnimation = True Then Exit Sub
  1608.     If KeyCode = vbKeyK Then CheatKeys = 1
  1609.     If KeyCode = vbKeyE And CheatKeys = 1 Then CheatKeys = 2
  1610.     If KeyCode = vbKeyN And CheatKeys = 2 Then CheatKeys = 3
  1611.     If KeyCode = vbKeyI And CheatKeys = 3 Then CheatKeys = 4
  1612.     If KeyCode = vbKeyS And CheatKeys = 4 Then CheatKeys = 5
  1613.     If KeyCode = vbKeyH And CheatKeys = 5 Then CheatKeys = 6
  1614.     If KeyCode = vbKeyO And CheatKeys = 6 Then CheatKeys = 7
  1615.     If KeyCode = vbKeyT And CheatKeys = 7 Then
  1616.         CheatKeys = 0
  1617.         If CheatActivated = False Then
  1618.             CheatActivated = True
  1619.             Exit Sub
  1620.         End If
  1621.         If CheatActivated = True Then
  1622.             CheatActivated = False
  1623.             Exit Sub
  1624.         End If
  1625.         
  1626.     End If
  1627.     
  1628.  
  1629.  
  1630.     If Paused = True Then Exit Sub
  1631.     If Gameover = True Then Exit Sub
  1632.     Select Case KeyCode
  1633.         Case 37 'Left
  1634.             MoveLeft
  1635.         Case 38 'Up
  1636.             PowerDrop
  1637.         Case 39 'Right
  1638.             MoveRight
  1639.         Case 40 'Down
  1640.             DropPiece
  1641.         Case 32 'Space
  1642.             RotatePiece
  1643.     End Select
  1644. End Sub
  1645.  
  1646. Private Sub tmrFlash_Timer()
  1647.     If LineAnimation = True Then
  1648.         For a = 0 To CountLines - 1
  1649.             For B = 0 To 9
  1650.                 GridColor(B, LinesErased(a)) = LineAnimationColor
  1651.             Next B
  1652.         Next a
  1653.         
  1654.         DrawGrid
  1655.         
  1656.         If LineAnimationColor = 11 Then
  1657.             LineAnimationColor = 10
  1658.             Exit Sub
  1659.         Else:
  1660.             LineAnimationColor = 11
  1661.             Exit Sub
  1662.         End If
  1663.     End If
  1664. End Sub
  1665.