Private Sub AddBall(Optional x As Integer = -1, Optional y As Integer = -1)
Dim cBall As New CBall
If x = -1 Then
cBall.x = Rnd(1, 100)
cBall.y = Rnd(1, 100)
Else
cBall.x = x
cBall.y = y
End If
cBall.ax = Rnd(-100, 100)
cBall.col = Rnd(1, 90000000)
objects.Add(cBall, Str(objects.Count + 1))
cB.Add(Str(objects.Count))
End
Private Sub DoGravity()
Dim myBall As CBall
For Each myBall In Objects
If togGrav.value Then myBall.ay = myBall.ay + world_Gravity '// Make Gravity
myBall.x = myBall.x + myBall.ax '// Move Ball
myBall.y = myBall.y + myBall.ay
If myBall.x >= dW.width - 5 Or myBall.x <= 0 Then '// Ball collidated on wall (left/right)
myBall.ax = (myBall.ax * world_Bounce) * -1 '// Reverse Ball direction and include world_Bounce
End If
If myBall.y > dW.Height - 10 Or myBall.y < 10 Then '// Ball collidated on Floor or Sky
If myball.y < 10 And togSky.value = False Then myball.ay = (myball.ay * world_Bounce) * -1 '// If Sky is disabled no not bounce
If myball.y > 10 Then myball.ay = (myball.ay * world_Bounce) * -1 '// On floor make bounce for sure
End If
If (((dW.Height - 10) - myBall.y) <= 1) And (Abs(myBall.ay) <= 2) And togGrav.Value Then '// If ball is n floor and to slow to jump up again stop the ball (y)
myball.y = (dW.Height - 10)
myball.ay = 0
End If
If myball.ay = 0 And myball.y = (dW.Height - 10) Then '// If ball is already on floor decrease the roll speed depending on world_SlideFloor factor.