by Johny Holmes (4 Submissions)
Category: Miscellaneous
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 6th April 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)
TABLE HOCKEY GAME. Code required to move images using the keyborad, and also getting images to bounce off the main image, ie. puck bouncing
Puck.Move Puck.Left + deltax, Puck.Top + deltay
If Puck.Left < Shape2.Left Then
deltax = 250
End If
If Puck.Left + Puck.Width > Shape2.Width + Shape2.Left Then
deltax = -250
End If
If Puck.Top < Shape2.Top Then deltay = 250
If Puck.Top + Puck.Height > Shape2.Height + Shape2.Top Then
deltay = -250
End If
**************************** FORM CODE *********************
'Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
PlayerL.Left = PlayerL.Left - 300
Case vbKeyRight
PlayerL.Left = PlayerL.Left + 300
Case vbKeyUp
PlayerL.Top = PlayerL.Top - 300
Case vbKeyDown
PlayerL.Top = PlayerL.Top + 300
End Select
'PlayerR = PlayerR PlayerL = PlayerL Puck = Puck
'if touch
If PlayerR.Left < Puck.Left + Puck.ScaleWidth And PlayerR.Left + PlayerR.ScaleWidth > Puck.Left And PlayerR.Top + PlayerR.ScaleHeight > Puck.Top And PlayerR.Top < Puck.Top + Puck.ScaleHeight Then
deltax = -350
deltay = 400
End If
If PlayerR.Left > Puck.Left + Puck.ScaleWidth And PlayerR.Left + PlayerR.ScaleWidth < Puck.Left And PlayerR.Top + PlayerR.ScaleHeight < Puck.Top And PlayerR.Top > Puck.Top + Puck.ScaleHeight Then
deltax = 350
deltay = -400
End If
If Puck.Left < PlayerL.Left + PlayerL.ScaleWidth And Puck.Left + Puck.ScaleWidth > PlayerL.Left And Puck.Top + Puck.ScaleHeight > PlayerL.Top And Puck.Top < PlayerR.Top + PlayerL.ScaleHeight Then
deltax = 350
deltay = 400
End If
If Puck.Left > PlayerL.Left + PlayerL.ScaleWidth And Puck.Left + Puck.ScaleWidth < PlayerL.Left And Puck.Top + Puck.ScaleHeight < PlayerL.Top And Puck.Top > PlayerL.Top + PlayerL.ScaleHeight Then
deltax = -350
deltay = -400
End If
*** ALSO THIS CODE ***
'Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 56 Then
PlayerR.Top = PlayerR.Top - 300
End If
If KeyAscii = 50 Then
PlayerR.Top = PlayerR.Top + 300
End If
If KeyAscii = 54 Then
PlayerR.Left = PlayerR.Left + 300
End If
If KeyAscii = 52 Then
PlayerR.Left = PlayerR.Left - 300
End If
No comments have been posted about TABLE HOCKEY GAME. Code required to move images using the keyborad, and also getting images to boun. Why not be the first to post a comment about TABLE HOCKEY GAME. Code required to move images using the keyborad, and also getting images to boun.