VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Table Top hockey

by Alfonso (1 Submission)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 30th November 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Table Top hockey

Rate Table Top hockey



Dim dirx As String
Dim diry As String
Dim speed
Dim score1
Dim score2

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'move picture1
Select Case KeyCode 'find out which key was pressed
        Case vbKeyUp 'the up arrow was pressed
            shpl.Top = shpl.Top - 500 'move player location
        Case vbKeyDown ' the down arrow was pressed
            shpl.Top = shpl.Top + 500 'move player location
        'Case vbKeyLeft 'the left arrow was pressed
           ' shpl.Left = shpl.Left - 500 'move player location
        'Case vbKeyRight 'the right arrow was pressed
           ' shpl.Left = shpl.Left + 500 'move player location
        Case Else 'no valid key was pressed, so
           Exit Sub 'exit the sub
    End Select

If shpl.Top > Form1.ScaleHeight - shpl.Height Then
    shpl.Top = shpl.Top - 450
    ElseIf shpl.Top < 0 Then
    shpl.Top = shpl.Top + 500
End If


End Sub

Private Sub Form_Load()


dirx = "R"
diry = "D"
speed = 150


End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
shpr.Top = Y
End Sub


Private Sub Label2_Click()

End Sub

Private Sub Timer1_Timer()
' make the ball move right to left
If dirx = "R" Then
    shpball.Left = shpball.Left + speed
ElseIf dirx = "L" Then
    shpball.Left = shpball.Left - speed
End If
If diry = "D" Then
    shpball.Top = shpball.Top + speed
ElseIf diry = "U" Then
    shpball.Top = shpball.Top - speed
End If

'right and left borders
If shpball.Left > Form1.ScaleWidth - shpball.Width Then
    
    dirx = "L"
    score1 = score1 + 1
    
ElseIf shpball.Left < 0 Then
    
    dirx = "R"
   score2 = score2 + 1
    
End If
If shpball.Top > Form1.ScaleHeight - shpball.Height Then
    diry = "U"
ElseIf shpball.Top < 0 Then
diry = "D"
End If


If Abs(shpr.Top - shpball.Top) < shpr.Height And shpball.Left + shpball.Width > shpr.Left Then
dirx = "L"
If speed < 650 Then
speed = speed + 10
End If
End If
If Abs(shpl.Top - shpball.Top) < shpl.Height And shpball.Left < shpl.Left + shplWidth + 150 Then
dirx = "R"
If speed < 650 Then
speed = speed + 10
End If
End If
lbls1 = "Player 2: " & score1
lbls2 = "Player 1: " & score2

If score1 = 5 Then
Timer1.Enabled = False
MsgBox "Player 2 wins with a game speed of " & speed, , "Winner"
score1 = 0
score2 = 0
speed = 100
Timer1.Enabled = True
End If

If score2 = 5 Then
Timer1.Enabled = False
MsgBox "Player 1 Wins with a game speed of " & speed, , "Winner"
score1 = 0
score2 = 0
speed = 100
Timer1.Enabled = True
End If
Form1.Caption = "Table Top Soccer                    Game Speed " & speed & " MPS"
End Sub


Download this snippet    Add to My Saved Code

Table Top hockey Comments

No comments have been posted about Table Top hockey. Why not be the first to post a comment about Table Top hockey.

Post your comment

Subject:
Message:
0/1000 characters