VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Extremely Simple code to have objects bounce around the screen. Modifies to Application size change

by The Kuiker (1 Submission)
Category: Games
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 16th March 2005
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Extremely Simple code to have objects bounce around the screen. Modifies to Application size changes

API Declarations


'CREATE:
'Create four timers; timUp, timBottom, timLeft, TimRight: All interval "1"
'Create a shape called shpBall

Rate Extremely Simple code to have objects bounce around the screen. Modifies to Application size change



timUp.Enabled = True
timLeft.Enabled = False
timBottom.Enabled = False
timRight.Enabled = True
End Sub

Private Sub timBottom_Timer()
shpball.Top = shpball.Top + Speed

If shpball.Top + shpball.Height >= Form1.ScaleHeight Then
    timUp.Enabled = True
    timBottom.Enabled = False
End If
End Sub

Private Sub timLeft_Timer()
shpball.Left = shpball.Left - Speed

If shpball.Left <= 0 Then
    timLeft.Enabled = False
    timRight.Enabled = True
End If
    
End Sub

Private Sub timRight_Timer()
shpball.Left = shpball.Left + Speed

If shpball.Left + shpball.Width >= Form1.ScaleWidth Then
    timLeft.Enabled = True
    timRight.Enabled = False
End If
End Sub

Private Sub timUp_Timer()
shpball.Top = shpball.Top - Speed

If shpball.Top <= 0 Then
    timUp.Enabled = False
    timBottom.Enabled = True
End If
End Sub


Download this snippet    Add to My Saved Code

Extremely Simple code to have objects bounce around the screen. Modifies to Application size change Comments

No comments have been posted about Extremely Simple code to have objects bounce around the screen. Modifies to Application size change. Why not be the first to post a comment about Extremely Simple code to have objects bounce around the screen. Modifies to Application size change.

Post your comment

Subject:
Message:
0/1000 characters