home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 3_2004-2005.ISO / Data / Zips / A_Four_Pla18173811122004.psc / FrmGame.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-11-12  |  35.8 KB  |  982 lines

  1. VERSION 5.00
  2. Begin VB.Form FrmGame 
  3.    BackColor       =   &H00000000&
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "4Pong"
  6.    ClientHeight    =   9975
  7.    ClientLeft      =   45
  8.    ClientTop       =   435
  9.    ClientWidth     =   13560
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   9975
  14.    ScaleWidth      =   13560
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.Frame Frame1 
  17.       BackColor       =   &H00000000&
  18.       Height          =   9735
  19.       Left            =   9960
  20.       TabIndex        =   0
  21.       Top             =   120
  22.       Width           =   3495
  23.       Begin VB.Label LblInformation 
  24.          BackStyle       =   0  'Transparent
  25.          Caption         =   $"FrmGame.frx":0000
  26.          BeginProperty Font 
  27.             Name            =   "Arial"
  28.             Size            =   9.75
  29.             Charset         =   0
  30.             Weight          =   400
  31.             Underline       =   0   'False
  32.             Italic          =   0   'False
  33.             Strikethrough   =   0   'False
  34.          EndProperty
  35.          ForeColor       =   &H00FFFFFF&
  36.          Height          =   1215
  37.          Index           =   2
  38.          Left            =   240
  39.          TabIndex        =   11
  40.          Top             =   8280
  41.          Width           =   3135
  42.       End
  43.       Begin VB.Label LblInformation 
  44.          BackStyle       =   0  'Transparent
  45.          Caption         =   "Please double click on a coloured name above to set who you will play as (up to 4 human players)."
  46.          BeginProperty Font 
  47.             Name            =   "Arial"
  48.             Size            =   9.75
  49.             Charset         =   0
  50.             Weight          =   400
  51.             Underline       =   0   'False
  52.             Italic          =   0   'False
  53.             Strikethrough   =   0   'False
  54.          EndProperty
  55.          ForeColor       =   &H00FFFFFF&
  56.          Height          =   855
  57.          Index           =   1
  58.          Left            =   240
  59.          TabIndex        =   10
  60.          Top             =   7320
  61.          Width           =   3135
  62.       End
  63.       Begin VB.Label LblInformation 
  64.          BackStyle       =   0  'Transparent
  65.          Caption         =   $"FrmGame.frx":009B
  66.          BeginProperty Font 
  67.             Name            =   "Arial"
  68.             Size            =   9.75
  69.             Charset         =   0
  70.             Weight          =   400
  71.             Underline       =   0   'False
  72.             Italic          =   0   'False
  73.             Strikethrough   =   0   'False
  74.          EndProperty
  75.          ForeColor       =   &H00FFFFFF&
  76.          Height          =   1455
  77.          Index           =   0
  78.          Left            =   240
  79.          TabIndex        =   9
  80.          Top             =   5880
  81.          Width           =   3135
  82.       End
  83.       Begin VB.Label LblScore 
  84.          BackStyle       =   0  'Transparent
  85.          Caption         =   "0"
  86.          BeginProperty Font 
  87.             Name            =   "Sylfaen"
  88.             Size            =   15.75
  89.             Charset         =   0
  90.             Weight          =   400
  91.             Underline       =   0   'False
  92.             Italic          =   -1  'True
  93.             Strikethrough   =   0   'False
  94.          EndProperty
  95.          ForeColor       =   &H00FFFFFF&
  96.          Height          =   375
  97.          Index           =   3
  98.          Left            =   600
  99.          TabIndex        =   8
  100.          Top             =   3840
  101.          Width           =   1815
  102.       End
  103.       Begin VB.Label LblScore 
  104.          BackStyle       =   0  'Transparent
  105.          Caption         =   "0"
  106.          BeginProperty Font 
  107.             Name            =   "Sylfaen"
  108.             Size            =   15.75
  109.             Charset         =   0
  110.             Weight          =   400
  111.             Underline       =   0   'False
  112.             Italic          =   -1  'True
  113.             Strikethrough   =   0   'False
  114.          EndProperty
  115.          ForeColor       =   &H00FFFFFF&
  116.          Height          =   375
  117.          Index           =   2
  118.          Left            =   600
  119.          TabIndex        =   7
  120.          Top             =   2760
  121.          Width           =   1815
  122.       End
  123.       Begin VB.Label LblScore 
  124.          BackStyle       =   0  'Transparent
  125.          Caption         =   "0"
  126.          BeginProperty Font 
  127.             Name            =   "Sylfaen"
  128.             Size            =   15.75
  129.             Charset         =   0
  130.             Weight          =   400
  131.             Underline       =   0   'False
  132.             Italic          =   -1  'True
  133.             Strikethrough   =   0   'False
  134.          EndProperty
  135.          ForeColor       =   &H00FFFFFF&
  136.          Height          =   375
  137.          Index           =   1
  138.          Left            =   600
  139.          TabIndex        =   6
  140.          Top             =   1680
  141.          Width           =   1815
  142.       End
  143.       Begin VB.Label LblScore 
  144.          BackStyle       =   0  'Transparent
  145.          Caption         =   "0"
  146.          BeginProperty Font 
  147.             Name            =   "Sylfaen"
  148.             Size            =   15.75
  149.             Charset         =   0
  150.             Weight          =   400
  151.             Underline       =   0   'False
  152.             Italic          =   -1  'True
  153.             Strikethrough   =   0   'False
  154.          EndProperty
  155.          ForeColor       =   &H00FFFFFF&
  156.          Height          =   375
  157.          Index           =   0
  158.          Left            =   600
  159.          TabIndex        =   5
  160.          Top             =   600
  161.          Width           =   1815
  162.       End
  163.       Begin VB.Label LblPlayer 
  164.          BackStyle       =   0  'Transparent
  165.          Caption         =   "Player 4"
  166.          BeginProperty Font 
  167.             Name            =   "Lucida Handwriting"
  168.             Size            =   12
  169.             Charset         =   0
  170.             Weight          =   700
  171.             Underline       =   0   'False
  172.             Italic          =   0   'False
  173.             Strikethrough   =   0   'False
  174.          EndProperty
  175.          ForeColor       =   &H00FF0000&
  176.          Height          =   375
  177.          Index           =   3
  178.          Left            =   120
  179.          TabIndex        =   4
  180.          Top             =   3480
  181.          Width           =   1575
  182.       End
  183.       Begin VB.Label LblPlayer 
  184.          BackStyle       =   0  'Transparent
  185.          Caption         =   "Player 3"
  186.          BeginProperty Font 
  187.             Name            =   "Lucida Handwriting"
  188.             Size            =   12
  189.             Charset         =   0
  190.             Weight          =   700
  191.             Underline       =   0   'False
  192.             Italic          =   0   'False
  193.             Strikethrough   =   0   'False
  194.          EndProperty
  195.          ForeColor       =   &H0000FFFF&
  196.          Height          =   375
  197.          Index           =   2
  198.          Left            =   120
  199.          TabIndex        =   3
  200.          Top             =   2400
  201.          Width           =   1575
  202.       End
  203.       Begin VB.Label LblPlayer 
  204.          BackStyle       =   0  'Transparent
  205.          Caption         =   "Player 2"
  206.          BeginProperty Font 
  207.             Name            =   "Lucida Handwriting"
  208.             Size            =   12
  209.             Charset         =   0
  210.             Weight          =   700
  211.             Underline       =   0   'False
  212.             Italic          =   0   'False
  213.             Strikethrough   =   0   'False
  214.          EndProperty
  215.          ForeColor       =   &H000080FF&
  216.          Height          =   375
  217.          Index           =   1
  218.          Left            =   120
  219.          TabIndex        =   2
  220.          Top             =   1320
  221.          Width           =   1575
  222.       End
  223.       Begin VB.Label LblPlayer 
  224.          BackStyle       =   0  'Transparent
  225.          Caption         =   "Player 1"
  226.          BeginProperty Font 
  227.             Name            =   "Lucida Handwriting"
  228.             Size            =   12
  229.             Charset         =   0
  230.             Weight          =   700
  231.             Underline       =   0   'False
  232.             Italic          =   0   'False
  233.             Strikethrough   =   0   'False
  234.          EndProperty
  235.          ForeColor       =   &H000000FF&
  236.          Height          =   375
  237.          Index           =   0
  238.          Left            =   120
  239.          TabIndex        =   1
  240.          Top             =   240
  241.          Width           =   1575
  242.       End
  243.    End
  244.    Begin VB.Timer TimGame 
  245.       Enabled         =   0   'False
  246.       Interval        =   5
  247.       Left            =   3600
  248.       Top             =   3000
  249.    End
  250.    Begin VB.Shape Ball 
  251.       BackColor       =   &H00FFFF00&
  252.       BackStyle       =   1  'Opaque
  253.       BorderColor     =   &H00FFFF00&
  254.       Height          =   375
  255.       Index           =   2
  256.       Left            =   5040
  257.       Shape           =   3  'Circle
  258.       Top             =   4080
  259.       Visible         =   0   'False
  260.       Width           =   375
  261.    End
  262.    Begin VB.Shape Ball 
  263.       BackColor       =   &H00FFFF00&
  264.       BackStyle       =   1  'Opaque
  265.       BorderColor     =   &H00FFFF00&
  266.       Height          =   375
  267.       Index           =   1
  268.       Left            =   4560
  269.       Shape           =   3  'Circle
  270.       Top             =   4080
  271.       Visible         =   0   'False
  272.       Width           =   375
  273.    End
  274.    Begin VB.Shape Ball 
  275.       BackColor       =   &H00FFFF00&
  276.       BackStyle       =   1  'Opaque
  277.       BorderColor     =   &H00FFFF00&
  278.       Height          =   375
  279.       Index           =   0
  280.       Left            =   4080
  281.       Shape           =   3  'Circle
  282.       Top             =   4080
  283.       Width           =   375
  284.    End
  285.    Begin VB.Shape CenterCircle 
  286.       BorderColor     =   &H0000FF00&
  287.       Height          =   375
  288.       Left            =   2880
  289.       Shape           =   3  'Circle
  290.       Top             =   3000
  291.       Width           =   375
  292.    End
  293.    Begin VB.Line Border 
  294.       BorderColor     =   &H0000FF00&
  295.       Index           =   5
  296.       X1              =   2880
  297.       X2              =   4080
  298.       Y1              =   2880
  299.       Y2              =   2880
  300.    End
  301.    Begin VB.Line Border 
  302.       BorderColor     =   &H0000FF00&
  303.       Index           =   4
  304.       X1              =   2880
  305.       X2              =   4080
  306.       Y1              =   2760
  307.       Y2              =   2760
  308.    End
  309.    Begin VB.Line Border 
  310.       BorderColor     =   &H0000FF00&
  311.       Index           =   3
  312.       X1              =   2880
  313.       X2              =   4080
  314.       Y1              =   2640
  315.       Y2              =   2640
  316.    End
  317.    Begin VB.Line Border 
  318.       BorderColor     =   &H0000FF00&
  319.       Index           =   2
  320.       X1              =   2880
  321.       X2              =   4080
  322.       Y1              =   2520
  323.       Y2              =   2520
  324.    End
  325.    Begin VB.Line Border 
  326.       BorderColor     =   &H0000FF00&
  327.       Index           =   1
  328.       X1              =   2880
  329.       X2              =   4080
  330.       Y1              =   2400
  331.       Y2              =   2400
  332.    End
  333.    Begin VB.Line Border 
  334.       BorderColor     =   &H0000FF00&
  335.       Index           =   0
  336.       X1              =   2880
  337.       X2              =   4080
  338.       Y1              =   2280
  339.       Y2              =   2280
  340.    End
  341.    Begin VB.Shape Pad 
  342.       BorderColor     =   &H00FF0000&
  343.       FillColor       =   &H00FF0000&
  344.       FillStyle       =   0  'Solid
  345.       Height          =   495
  346.       Index           =   3
  347.       Left            =   3960
  348.       Top             =   1560
  349.       Width           =   255
  350.    End
  351.    Begin VB.Shape Pad 
  352.       BorderColor     =   &H0000FFFF&
  353.       FillColor       =   &H0000FFFF&
  354.       FillStyle       =   0  'Solid
  355.       Height          =   495
  356.       Index           =   2
  357.       Left            =   3600
  358.       Top             =   1560
  359.       Width           =   255
  360.    End
  361.    Begin VB.Shape Pad 
  362.       BorderColor     =   &H000080FF&
  363.       FillColor       =   &H000080FF&
  364.       FillStyle       =   0  'Solid
  365.       Height          =   495
  366.       Index           =   1
  367.       Left            =   3240
  368.       Top             =   1560
  369.       Width           =   255
  370.    End
  371.    Begin VB.Shape Pad 
  372.       BorderColor     =   &H000000FF&
  373.       FillColor       =   &H000000FF&
  374.       FillStyle       =   0  'Solid
  375.       Height          =   495
  376.       Index           =   0
  377.       Left            =   2880
  378.       Top             =   1560
  379.       Width           =   255
  380.    End
  381. Attribute VB_Name = "FrmGame"
  382. Attribute VB_GlobalNameSpace = False
  383. Attribute VB_Creatable = False
  384. Attribute VB_PredeclaredId = True
  385. Attribute VB_Exposed = False
  386. '''''''''''''''''''''''''''''''''''''
  387. '' 4Pong By Dominic 'Phenix' Black ''
  388. ''                                 ''
  389. '' Feel free to use any code in    ''
  390. '' your own programs, just give me ''
  391. '' credits for the bits from this  ''
  392. '' program.                        ''
  393. ''                                 ''
  394. '' I hope my code is readable! :P  ''
  395. ''                                 ''
  396. '' Any questions please email me;  ''
  397. '' phenix@filesnetwork.com         ''
  398. '''''''''''''''''''''''''''''''''''''
  399. ' Please comment on my code at: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=57208&lngWId=1
  400. ' Thank you!
  401. ' Constant Settings
  402. Const Pad_Width As Integer = 100
  403. Const Pad_Height As Integer = 1250
  404. Const Pad_Padding As Integer = 100
  405. Const Pad_Speed As Integer = 75
  406. Const Border_Differance As Integer = 50
  407. Const Centre_Circle As Integer = 2000
  408. Const Min_Speed As Integer = 5
  409. Const Max_Speed As Integer = 30
  410. Const Rebound_Effect As Single = 0.1
  411. Const Form_Width As Integer = 9960 'Have to use consts because otherwise it is wrong...
  412. Const Form_Height As Integer = 9960 ' ...using frmgame.width or frmgame.height
  413. Const debugOn As Boolean = False
  414. ' Variables
  415. Dim Computer(0 To 3) As Boolean
  416. Dim Difficultly As Integer '1 = hard, 2 = median, 3 = easy
  417. Dim hMom(0 To 2) As Single
  418. Dim vMom(0 To 2) As Single
  419. Dim MovePad(0 To 3, 1 To 2) As Integer
  420. Dim Score(0 To 3) As Integer
  421. Dim FunkyGraphics As Boolean
  422. Dim Place As Integer
  423. Dim Max_Score As Integer
  424. Dim Game_Started As Boolean
  425. Private Sub Reset_Game(Optional ByPass As Boolean = True)
  426.     Dim DoReset As Boolean
  427.     Dim i As Integer
  428.         
  429.     ' Check with the user if we're not intructed to bypass the msgbox
  430.     If ByPass = True Then
  431.         DoReset = True
  432.     Else
  433.         'If he really wants to reset let him, else continue
  434.         If MsgBox("Are you sure you want to restart the game?", vbQuestion Or vbYesNo, "4Pong") = vbYes Then
  435.             DoReset = True
  436.             For i = 0 To 3
  437.                 Score(i) = 0
  438.                 LblScore(i).Caption = "0"
  439.                 Pad(i).Visible = True
  440.             Next
  441.             Place = 4
  442.             
  443.         Else
  444.             DoReset = False
  445.         End If
  446.     End If
  447.     'Reset window
  448.     If DoReset = True Then
  449.         'Pad 0 - Left
  450.         With Pad(0)
  451.             .Width = Pad_Width
  452.             .Height = Pad_Height
  453.             .Left = Pad_Padding
  454.             .Top = (Form_Height / 2) - (Pad_Height / 2)
  455.         End With
  456.         
  457.         'Pad 1 - Top
  458.         With Pad(1)
  459.             .Width = Pad_Height
  460.             .Height = Pad_Width
  461.             .Left = (Form_Width / 2) - (Pad_Height / 2)
  462.             .Top = Pad_Padding
  463.         End With
  464.         
  465.         'Pad 2 - Right
  466.         With Pad(2)
  467.             .Width = Pad_Width
  468.             .Height = Pad_Height
  469.             .Left = Form_Width - (Pad_Padding + Pad_Width)
  470.             .Top = (Form_Height / 2) - (Pad_Height / 2)
  471.         End With
  472.         
  473.         'Pad 3 - Bottom
  474.         With Pad(3)
  475.             .Width = Pad_Height
  476.             .Height = Pad_Width
  477.             .Left = (Form_Width / 2) - (Pad_Height / 2)
  478.             .Top = Form_Height - (Pad_Padding + Pad_Width)
  479.         End With
  480.         
  481.         'Border - Left
  482.         With Border(0)
  483.             .X1 = Pad_Padding - Border_Differance
  484.             .X2 = Pad_Padding - Border_Differance
  485.             .Y1 = Pad_Padding - Border_Differance
  486.             .Y2 = Form_Height - (Pad_Padding - Border_Differance)
  487.         End With
  488.         
  489.         'Border - Top
  490.         With Border(1)
  491.             .X1 = Pad_Padding - Border_Differance
  492.             .X2 = Form_Width - (Pad_Padding - Border_Differance)
  493.             .Y1 = Pad_Padding - Border_Differance
  494.             .Y2 = Pad_Padding - Border_Differance
  495.         End With
  496.         
  497.         'Border - Right
  498.         With Border(2)
  499.             .X1 = Form_Width - (Pad_Padding - Border_Differance)
  500.             .X2 = Form_Width - (Pad_Padding - Border_Differance)
  501.             .Y1 = Pad_Padding - Border_Differance
  502.             .Y2 = Form_Height - (Pad_Padding - Border_Differance)
  503.         End With
  504.         
  505.         'Border - Bottom
  506.         With Border(3)
  507.             .X1 = Form_Width - (Pad_Padding - Border_Differance)
  508.             .X2 = Pad_Padding - Border_Differance
  509.             .Y1 = Form_Height - (Pad_Padding - Border_Differance)
  510.             .Y2 = Form_Height - (Pad_Padding - Border_Differance)
  511.         End With
  512.         
  513.         'Border - Dia 1
  514.         With Border(4)
  515.             .X1 = Pad_Padding - Border_Differance
  516.             .X2 = Form_Width - (Pad_Padding - Border_Differance)
  517.             .Y1 = Pad_Padding - Border_Differance
  518.             .Y2 = Form_Height - (Pad_Padding - Border_Differance)
  519.         End With
  520.         
  521.         'Border - Dia 2
  522.         With Border(5)
  523.             .X1 = Pad_Padding - Border_Differance
  524.             .X2 = Form_Width - (Pad_Padding - Border_Differance)
  525.             .Y1 = Form_Height - (Pad_Padding - Border_Differance)
  526.             .Y2 = Pad_Padding - Border_Differance
  527.         End With
  528.         
  529.         'Centre Circle
  530.         With CenterCircle
  531.             .Left = (Form_Width / 2) - (Centre_Circle / 2)
  532.             .Top = (Form_Height / 2) - (Centre_Circle / 2)
  533.             .Width = Centre_Circle
  534.             .Height = Centre_Circle
  535.         End With
  536.             
  537.         'Set Ball 0 up
  538.         With Ball(0)
  539.             .Top = (Form_Height / 2) - (.Height / 2)
  540.             .Left = (Form_Width / 2) - (.Width / 2)
  541.             .Visible = True
  542.         End With
  543.         
  544.         'Give speed to Ball 0
  545.         RandomSpeeds 0
  546.         
  547.         'Reset pad movement speeds
  548.         For i = 0 To 3
  549.             MovePad(i, 1) = 0
  550.             MovePad(i, 2) = 0
  551.         Next
  552.         
  553.         'Set other balls up
  554.         Ball(1).Visible = False
  555.         Ball(2).Visible = False
  556.         
  557.         'Disable Timer
  558.         If AllComputers = False Or Game_Started <> True Then
  559.             TimGame.Enabled = False
  560.             Game_Started = True
  561.             If AllComputers = True Then TimGame.Interval = 1
  562.         End If
  563.     End If
  564. End Sub
  565. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  566.     Select Case KeyCode
  567.         Case vbKeyNumpad8
  568.             MovePad(3, 2) = -Pad_Speed
  569.         Case vbKeyNumpad9
  570.             MovePad(3, 2) = Pad_Speed
  571.         Case vbKeyUp
  572.             MovePad(2, 1) = -Pad_Speed
  573.         Case vbKeyDown
  574.             MovePad(2, 1) = Pad_Speed
  575.         Case vbKeyK
  576.             MovePad(1, 2) = -Pad_Speed
  577.         Case vbKeyL
  578.             MovePad(1, 2) = Pad_Speed
  579.         Case vbKeyQ
  580.             MovePad(0, 1) = -Pad_Speed
  581.         Case vbKeyA
  582.             MovePad(0, 1) = Pad_Speed
  583.     End Select
  584. End Sub
  585. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
  586.     Select Case KeyCode
  587.         Case vbKeyPause
  588.             'Pause / Resume game
  589.             If Place <> 1 Then TimGame.Enabled = Not TimGame.Enabled
  590.         Case vbKeyF2
  591.             'Player wants to restart
  592.             Reset_Game False
  593.             
  594.         Case vbKeyNumpad8
  595.             MovePad(3, 2) = 0
  596.         Case vbKeyNumpad9
  597.             MovePad(3, 2) = 0
  598.         Case vbKeyUp
  599.             MovePad(2, 1) = 0
  600.         Case vbKeyDown
  601.             MovePad(2, 1) = 0
  602.         Case vbKeyK
  603.             MovePad(1, 2) = 0
  604.         Case vbKeyL
  605.             MovePad(1, 2) = 0
  606.         Case vbKeyQ
  607.             MovePad(0, 1) = 0
  608.         Case vbKeyA
  609.             MovePad(0, 1) = 0
  610.         
  611.         'Debug Keys
  612.         Case vbKeyF12
  613.             'Check explodeballs function
  614.             If debugOn = True Then ExplodeBalls
  615.             
  616.     End Select
  617. End Sub
  618. Private Sub Form_Load()
  619.     On Error GoTo errorHnd
  620.     'Load window positions and other settings
  621.     Dim i As Integer
  622.     For i = 0 To 3
  623.         Computer(i) = True
  624.         LblPlayer(i).Caption = "Computer"
  625.     Next
  626.     Place = 4
  627.     Reset_Game
  628. Retry:
  629.     Difficultly = InputBox("Please enter a difficulty setting." & vbNewLine & vbNewLine & _
  630.                             "1 for Hard" & vbNewLine & "2 for Average" & vbNewLine & "3 for Easy", _
  631.                             "4Pong Settings", "1")
  632.     Max_Score = InputBox("Please enter a max score before a player will be removed for letting the ball of his side that ammount of times", "4Pong Settings", "10")
  633.     Game_Started = False
  634.     Exit Sub
  635. errorHnd:
  636.     MsgBox "An error was dectected on your input please make sure that you enter numbers only.", vbCritical, "4Pong: Error"
  637.     GoTo Retry
  638. End Sub
  639. Private Sub Form_Unload(Cancel As Integer)
  640.     If MsgBox("Are you sure you wish to quit?", vbQuestion Or vbYesNo, "4Pong") = vbNo Then
  641.         Cancel = 1
  642.     Else
  643.         MsgBox "Thank you for downloading my four player pong game." & vbNewLine & vbNewLine & " - Dom", vbInformation Or vbOKOnly, "4Pong - Thank you"
  644.         End
  645.     End If
  646. End Sub
  647. Private Sub LblPlayer_DblClick(Index As Integer)
  648.     If Game_Started <> True Then
  649.         Dim newName As String
  650.         
  651.         newName = InputBox("Please enter a name for player " & (Index + 1) & "." & vbNewLine & vbNewLine & "(Enter computer for a computer player.)", "4Pong")
  652.         
  653.         If UCase(newName) = "COMPUTER" Then
  654.             LblPlayer(Index).Caption = "Computer"
  655.             Computer(Index) = True
  656.         Else
  657.             LblPlayer(Index).Caption = newName
  658.             Computer(Index) = False
  659.             
  660.             Select Case Index
  661.                 Case 0
  662.                     MsgBox newName & "'s controls are:" & vbNewLine & vbNewLine & _
  663.                         "Q for up" & vbNewLine & "A for down", vbInformation Or _
  664.                         vbOKOnly, "4Pong Player Controls"
  665.                 Case 1
  666.                     MsgBox newName & "'s controls are:" & vbNewLine & vbNewLine & _
  667.                         "< for left" & vbNewLine & "> for right", vbInformation Or _
  668.                         vbOKOnly, "4Pong Player Controls"
  669.                 Case 2
  670.                     MsgBox newName & "'s controls are:" & vbNewLine & vbNewLine & _
  671.                         "Up Key for up" & vbNewLine & "Down Key for down", vbInformation Or _
  672.                         vbOKOnly, "4Pong Player Controls"
  673.                 Case 3
  674.                     MsgBox newName & "'s controls are:" & vbNewLine & vbNewLine & _
  675.                         "8 (NumPad) for left" & vbNewLine & "9 (NumPad) for right", vbInformation Or _
  676.                         vbOKOnly, "4Pong Player Controls"
  677.             End Select
  678.         End If
  679.     End If
  680. End Sub
  681. Private Sub TimGame_Timer()
  682.     Dim i, j As Integer
  683.     Dim smallest, num As Integer
  684.     If debugOn = True And FunkyGraphics <> False Then
  685.         CenterCircle.Width = CenterCircle.Width - 50
  686.         CenterCircle.Height = CenterCircle.Height - 50
  687.         CenterCircle.Left = (Form_Width / 2) - (CenterCircle.Width / 2)
  688.         CenterCircle.Top = (Form_Height / 2) - (CenterCircle.Height / 2)
  689.         With Border(4)
  690.             .X1 = Border(4).X1 - ((Border(3).X2 - Border(3).X1) / 30)
  691.             .X2 = Border(4).X2 + ((Border(3).X2 - Border(3).X1) / 30)
  692.         End With
  693.         With Border(5)
  694.             .Y1 = Border(5).Y1 - ((Border(2).Y2 - Border(2).Y1) / 30)
  695.             .Y2 = Border(5).Y2 + ((Border(2).Y2 - Border(2).Y1) / 30)
  696.         End With
  697.         If CenterCircle.Height <= 500 Then FunkyGraphics = False
  698.     ElseIf debugOn = True Then
  699.         CenterCircle.Width = CenterCircle.Width + 50
  700.         CenterCircle.Height = CenterCircle.Height + 50
  701.         CenterCircle.Left = (Form_Width / 2) - (CenterCircle.Width / 2)
  702.         CenterCircle.Top = (Form_Height / 2) - (CenterCircle.Height / 2)
  703.         With Border(4)
  704.             .X1 = Border(4).X1 + ((Border(3).X2 - Border(3).X1) / 30)
  705.             .X2 = Border(4).X2 - ((Border(3).X2 - Border(3).X1) / 30)
  706.         End With
  707.         With Border(5)
  708.             .Y1 = Border(5).Y1 + ((Border(2).Y2 - Border(2).Y1) / 30)
  709.             .Y2 = Border(5).Y2 - ((Border(2).Y2 - Border(2).Y1) / 30)
  710.         End With
  711.         If CenterCircle.Height >= 2000 Then FunkyGraphics = True
  712.     End If
  713.     'Loop though players
  714.     For i = 0 To 3
  715.         If Computer(i) = False Then
  716.             
  717.         Else
  718.             If i = 0 Then
  719.                 num = 32000
  720.                 For j = 0 To 2
  721.                     If Ball(j).Visible = True Then
  722.                         If num > Ball(j).Left - Pad(i).Left And (Ball(j).Left - Pad(i).Left) > 0 Then
  723.                             smallest = j
  724.                             num = Ball(j).Left - Pad(i).Left
  725.                         End If
  726.                     End If
  727.                 Next
  728.                 
  729.                 If Ball(smallest).Top < Pad(i).Top Then
  730.                     MovePad(i, 1) = -(Pad_Speed / Difficultly)
  731.                 ElseIf Ball(smallest).Top > Pad(i).Top + Pad_Height Then
  732.                     MovePad(i, 1) = (Pad_Speed / Difficultly)
  733.                 Else
  734.                     MovePad(i, 1) = 0
  735.                 End If
  736.             ElseIf i = 1 Then
  737.                 num = 32000
  738.                 For j = 0 To 2
  739.                     If Ball(j).Visible = True Then
  740.                         If num > Ball(j).Top - Pad(i).Top And (Ball(j).Top - Pad(i).Top) > 0 Then
  741.                             smallest = j
  742.                             num = Ball(j).Top - Pad(i).Top
  743.                         End If
  744.                     End If
  745.                 Next
  746.                 
  747.                 If Ball(smallest).Left < Pad(i).Left Then
  748.                     MovePad(i, 2) = -(Pad_Speed / Difficultly)
  749.                 ElseIf Ball(smallest).Left > Pad(i).Left + Pad_Width Then
  750.                     MovePad(i, 2) = (Pad_Speed / Difficultly)
  751.                 Else
  752.                     MovePad(i, 2) = 0
  753.                 End If
  754.             ElseIf i = 2 Then
  755.                 num = 32000
  756.                 For j = 0 To 2
  757.                     If Ball(j).Visible = True Then
  758.                         If num > Pad(i).Left - Ball(j).Left And (Pad(i).Left - Ball(j).Left) > 0 Then
  759.                             smallest = j
  760.                             num = Pad(i).Left - Ball(j).Left
  761.                         End If
  762.                     End If
  763.                 Next
  764.                 
  765.                 If Ball(smallest).Top < Pad(i).Top Then
  766.                     MovePad(i, 1) = -(Pad_Speed / Difficultly)
  767.                 ElseIf Ball(smallest).Top > Pad(i).Top + Pad_Height Then
  768.                     MovePad(i, 1) = (Pad_Speed / Difficultly)
  769.                 Else
  770.                     MovePad(i, 1) = 0
  771.                 End If
  772.             ElseIf i = 3 Then
  773.                 num = 32000
  774.                 For j = 0 To 2
  775.                     If Ball(j).Visible = True Then
  776.                         If num > Pad(i).Top - Ball(j).Top And (Pad(i).Top - Ball(j).Top) > 0 Then
  777.                             smallest = j
  778.                             num = Pad(i).Top - Ball(j).Top
  779.                         End If
  780.                     End If
  781.                 Next
  782.                 
  783.                 If Ball(smallest).Left < Pad(i).Left Then
  784.                     MovePad(i, 2) = -(Pad_Speed / Difficultly)
  785.                 ElseIf Ball(smallest).Left > Pad(i).Left + Pad_Width Then
  786.                     MovePad(i, 2) = (Pad_Speed / Difficultly)
  787.                 Else
  788.                     MovePad(i, 2) = 0
  789.                 End If
  790.             End If
  791.         End If
  792.     Next
  793.     For i = 0 To 3
  794.         Pad(i).Left = Pad(i).Left + MovePad(i, 2)
  795.         Pad(i).Top = Pad(i).Top + MovePad(i, 1)
  796.     Next
  797.     If Pad(0).Top < Pad_Padding Then Pad(0).Top = Pad_Padding
  798.     If Pad(2).Top < Pad_Padding Then Pad(2).Top = Pad_Padding
  799.     If Pad(0).Top > Form_Height - (Pad_Padding + Pad_Width) Then Pad(0).Top = Form_Height - (Pad_Padding + Pad_Width)
  800.     If Pad(2).Top > Form_Height - (Pad_Padding + Pad_Width) Then Pad(2).Top = Form_Height - (Pad_Padding + Pad_Width)
  801.     If Pad(0).Left < Pad_Padding Then Pad(0).Left = Pad_Padding
  802.     If Pad(2).Left > Form_Width - (Pad_Padding + Pad_Width) Then Pad(2).Left = Form_Width - (Pad_Padding + Pad_Width)
  803.     If Pad(1).Top < Pad_Padding Then Pad(1).Top = Pad_Padding
  804.     If Pad(3).Top < Form_Height - (Pad_Padding + Pad_Width) Then Pad(3).Top = Form_Height - (Pad_Padding + Pad_Width)
  805.     If Pad(1).Left < Pad_Padding Then Pad(1).Left = Pad_Padding
  806.     If Pad(1).Left > Form_Width - (Pad_Padding + Pad_Height) Then Pad(1).Left = Form_Width - (Pad_Padding + Pad_Height)
  807.     If Pad(3).Left < Pad_Padding Then Pad(3).Left = Pad_Padding
  808.     If Pad(3).Left > Form_Width - (Pad_Padding + Pad_Height) Then Pad(3).Left = Form_Width - (Pad_Padding + Pad_Height)
  809.     'Loop though balls
  810.     For i = 0 To 2
  811.         ' If the ball is visible then
  812.         If Ball(i).Visible = True Then
  813.             'Move this ball
  814.             Ball(i).Left = Ball(i).Left + hMom(i)
  815.             Ball(i).Top = Ball(i).Top + vMom(i)
  816.             If (Ball(i).Left <= Pad(0).Left + Pad(0).Width And _
  817.             Ball(i).Top >= Pad(0).Top - Ball(i).Height And _
  818.             Ball(i).Top <= Pad(0).Top + Pad(0).Height And _
  819.             Ball(i).Left >= Pad(0).Left - Ball(i).Width) And Pad(0).Visible = True Then
  820.                 Ball(i).Left = Pad(0).Left + Pad(0).Width
  821.                 tmp = ((Pad(0).Top + (Pad(0).Height / 2)) - (Ball(i).Top + (Ball(i).Height / 2))) * Rebound_Effect
  822.                 hMom(i) = -hMom(i)
  823.                 vMom(i) = vMom(i) - tmp
  824.             End If
  825.             
  826.             If Ball(i).Left >= Pad(2).Left - Ball(i).Width And _
  827.             Ball(i).Top >= Pad(2).Top - Ball(i).Height And _
  828.             Ball(i).Top <= Pad(2).Top + Pad(2).Height And _
  829.             Ball(i).Left <= Pad(2).Left + Pad(2).Width + Ball(i).Width And Pad(2).Visible = True Then
  830.                 Ball(i).Left = Pad(2).Left - Ball(i).Width
  831.                 tmp = ((Pad(2).Top + (Pad(2).Height / 2)) - (Ball(i).Top + (Ball(i).Height / 2))) * Rebound_Effect
  832.                 hMom(i) = -hMom(i)
  833.                 vMom(i) = vMom(i) - tmp
  834.             End If
  835.             
  836.             If Ball(i).Top <= Pad(1).Top + Pad(1).Height And _
  837.             Ball(i).Left >= Pad(1).Left - Ball(i).Width And _
  838.             Ball(i).Left <= Pad(1).Left + Pad(1).Width And _
  839.             Ball(i).Top >= Pad(1).Top - Ball(i).Height And Pad(1).Visible = True Then
  840.                 Ball(i).Top = Pad(1).Top + Pad(1).Height
  841.                 tmp = ((Pad(1).Left + (Pad(1).Width / 2)) - (Ball(i).Left + (Ball(i).Width / 2))) * Rebound_Effect
  842.                 vMom(i) = -vMom(i)
  843.                 hMom(i) = hMom(i) - tmp
  844.             End If
  845.             
  846.             If Ball(i).Top >= Pad(3).Top - Ball(i).Height And _
  847.             Ball(i).Left >= Pad(3).Left - Ball(i).Width And _
  848.             Ball(i).Left <= Pad(3).Left + Pad(3).Width And _
  849.             Ball(i).Top <= Pad(3).Top + Pad(3).Height + Ball(i).Height And Pad(3).Visible = True Then
  850.                 Ball(i).Top = Pad(3).Top - Ball(i).Height
  851.                 tmp = ((Pad(3).Left + (Pad(3).Width / 2)) - (Ball(i).Left + (Ball(i).Width / 2))) * Rebound_Effect
  852.                 vMom(i) = -vMom(i)
  853.                 hMom(i) = hMom(i) - tmp
  854.             End If
  855.             
  856.             If Pad(0).Visible = False And Ball(i).Left <= Border(0).X1 Then
  857.                 hMom(i) = -hMom(i)
  858.             End If
  859.             
  860.             If Pad(2).Visible = False And Ball(i).Left >= Border(2).X1 - Ball(i).Width Then
  861.                 hMom(i) = -hMom(i)
  862.             End If
  863.             
  864.             If Pad(1).Visible = False And Ball(i).Top <= Border(1).Y1 Then
  865.                 vMom(i) = -vMom(i)
  866.             End If
  867.             
  868.             If Pad(3).Visible = False And Ball(i).Top >= Border(3).Y1 - Ball(i).Height Then
  869.                 vMom(i) = -vMom(i)
  870.             End If
  871.             
  872.             'If it goes off an edge add a score to somebody
  873.             If Ball(i).Left <= Border(0).X1 And Pad(0).Visible = True Then AddScore 0, i
  874.             If Ball(i).Left >= Border(2).X1 And Pad(2).Visible = True Then AddScore 2, i
  875.             If Ball(i).Top <= Border(1).Y1 And Pad(1).Visible = True Then AddScore 1, i
  876.             If Ball(i).Top >= Border(3).Y1 And Pad(3).Visible = True Then AddScore 3, i
  877.         End If
  878.         
  879.         If Rnd() > 0.95 Then
  880.             If Rnd() > 0.95 Then
  881.                 If Rnd() > 0.95 Then
  882.                     ExplodeBalls
  883.                 End If
  884.             End If
  885.         End If
  886.     Next
  887. End Sub
  888. Private Sub AddScore(Player As Integer, ByVal ballNum As Integer)
  889.     Dim i As Integer
  890.     'Add a "bad" score to the player's who side it went off
  891.     Score(Player) = Score(Player) + 1
  892.     LblScore(Player).Caption = "-" & Score(Player)
  893.     'Make the ball invisible (incase more are on the field)
  894.     Ball(ballNum).Visible = False
  895.     If Score(Player) >= Max_Score Then
  896.         Pad(Player).Visible = False
  897.         Select Case Place
  898.             Case 2
  899.                 For i = 0 To 3
  900.                     If Pad(i).Visible = True Then Exit For
  901.                 Next
  902.                 LblScore(i).Caption = "First Place"
  903.                 LblScore(Player).Caption = "Second Place"
  904.                 Place = 1
  905.                 TimGame.Enabled = False
  906.             Case 3
  907.                 LblScore(Player).Caption = "Third Place"
  908.                 Place = 2
  909.             Case 4
  910.                 LblScore(Player).Caption = "Last Place"
  911.                 Place = 3
  912.         End Select
  913.     End If
  914.         
  915.     'If no balls are left reset game window
  916.     If CountBalls = 0 Then Reset_Game
  917. End Sub
  918. Private Sub ExplodeBalls()
  919.     Dim i As Integer
  920.     If CountBalls = 1 Then
  921.         If Ball(0).Visible = False Then
  922.             For i = 1 To 2
  923.                 If Ball(i).Visible = True Then
  924.                     Ball(0).Left = Ball(i).Left
  925.                     Ball(0).Top = Ball(i).Top
  926.                     hMom(0) = hMom(i)
  927.                     vMom(0) = vMom(i)
  928.                 End If
  929.             Next
  930.         End If
  931.         
  932.         'Set each ball into the same position and make it visible
  933.         For i = 1 To 2
  934.             Ball(i).Left = Ball(0).Left
  935.             Ball(i).Top = Ball(0).Top
  936.             Ball(i).Visible = True
  937.         Next
  938.         
  939.         Ball(0).Visible = True
  940.         
  941.         'Give all balls new speeds
  942.         For i = 1 To 2
  943.             RandomSpeeds i
  944.         Next
  945.     End If
  946. End Sub
  947. Private Sub RandomSpeeds(ballNum As Integer)
  948.     Randomize
  949.     hMom(ballNum) = (Int(Rnd() * Max_Speed) - (Max_Speed / 2)) * 2
  950.     vMom(ballNum) = (Int(Rnd() * Max_Speed) - (Max_Speed / 2)) * 2
  951.     If hMom(ballNum) < 0 Then
  952.         hMom(ballNum) = hMom(ballNum) - Min_Speed
  953.     Else
  954.         hMom(ballNum) = hMom(ballNum) + Min_Speed
  955.     End If
  956.     If vMom(ballNum) < 0 Then
  957.         vMom(ballNum) = vMom(ballNum) - Min_Speed
  958.     Else
  959.         vMom(ballNum) = vMom(ballNum) + Min_Speed
  960.     End If
  961. End Sub
  962. Private Function CountBalls() As Integer
  963.     Dim i, count As Integer
  964.     'Check how many balls are left
  965.     count = 0
  966.     For i = 0 To 2
  967.         If Ball(i).Visible = True Then count = count + 1
  968.     Next
  969.     'Return Value
  970.     CountBalls = count
  971. End Function
  972. Private Function AllComputers() As Boolean
  973.     Dim i As Integer
  974.     For i = 0 To 3
  975.         If Computer(i) <> True And Pad(i).Visible = True Then
  976.             AllComputers = False
  977.             Exit Function
  978.         End If
  979.     Next
  980.     AllComputers = True
  981. End Function
  982.