VERSION 5.00
Begin VB.Form frmPilka 
   Caption         =   "Ping-pong"
   ClientHeight    =   4428
   ClientLeft      =   48
   ClientTop       =   336
   ClientWidth     =   6276
   LinkTopic       =   "Form1"
   ScaleHeight     =   4428
   ScaleWidth      =   6276
   StartUpPosition =   3  'Windows-Standard
   Begin VB.Timer tmrTimer 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   5520
      Top             =   3840
   End
   Begin VB.CommandButton cmdStop 
      Caption         =   "Sto&p"
      Height          =   372
      Left            =   4068
      TabIndex        =   1
      Top             =   3480
      Width           =   972
   End
   Begin VB.CommandButton cmdStart 
      Caption         =   "&Start"
      Height          =   372
      Left            =   1236
      TabIndex        =   0
      Top             =   3480
      Width           =   972
   End
   Begin VB.Line Line1 
      BorderWidth     =   3
      X1              =   0
      X2              =   6372
      Y1              =   3200
      Y2              =   3200
   End
   Begin VB.Shape shpPilka 
      BackColor       =   &H000000FF&
      BackStyle       =   1  'Nieprzezroczysty
      BorderColor     =   &H00000000&
      Height          =   372
      Left            =   2952
      Shape           =   3  'Koło
      Top             =   1800
      Width           =   372
   End
End
Attribute VB_Name = "frmPilka"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim WartoscX As Integer
Dim WartoscY As Integer

Private Sub Form_Load()
    WartoscX = 90  ' ustawienia zależą od szybkości komputera
    WartoscY = 75  '          "
End Sub

Private Sub cmdStart_Click()
    tmrTimer.Enabled = True
End Sub

Private Sub cmdStop_Click()
    tmrTimer.Enabled = False
End Sub

Private Sub tmrTimer_Timer()
    shpPilka.Left = shpPilka.Left + WartoscX
    shpPilka.Top = shpPilka.Top + WartoscY
    
    If shpPilka.Top <= 0 Then WartoscY = -WartoscY
    If shpPilka.Left <= 0 Then WartoscX = -WartoscX
    
    If (shpPilka.Top + shpPilka.Height) >= Line1.Y1 Then WartoscY = -WartoscY
    If (shpPilka.Left + shpPilka.Width) >= ScaleWidth Then WartoscX = -WartoscX
End Sub

