- Home
·
- Graphics
·
- an update to my original bounce program has bounce count, plots that follow the ball, start/stop bu
an update to my original bounce program has bounce count, plots that follow the ball, start/stop bu
an update to my original bounce program has bounce count, plots that follow the ball, start/stop button, reference points, and lines
Rate an update to my original bounce program has bounce count, plots that follow the ball, start/stop bu
(2(2 Vote))
Private BoundX As Integer
Private BoundY As Integer
Private circlePosX As Integer
Private circlePosY As Integer
Private isRight As Boolean
Private isDown As Boolean
'Private ValRnd As Byte
Private accumulator As Integer
Private Sub Command1_Click()
If Command1.Caption = "Stop" Then
Timer1.Enabled = False
Command1.Caption = "Start"
Else
Timer1.Enabled = True
Command1.Caption = "Stop"
End If
End Sub
Private Sub Form_Load()
isRight = True
isDown = True
End Sub
Private Sub Timer1_Timer()
Command1.Left = 4
Command1.Top = 4
BoundY = Form1.ScaleHeight - (Shape1.Height / 2) 'greater equals down
BoundX = Form1.Width - (Shape1.Width / 2)
Shape1.Top = circlePosY
Shape1.Left = circlePosX
'write the plots and follow the ball
Label1.Caption = circlePosX / 250
Label2.Caption = circlePosY / 250
Label1.Top = circlePosY + 200
Label1.Left = circlePosX + 200
Label2.Top = (Label1.Top)
Label2.Left = (Label1.Left + Label1.Width)
'centers point in form
Shape2.Left = (BoundX / 2)
Shape2.Top = ((3 / 4) * BoundY)
Shape3.Left = (BoundX / 2)
Shape3.Top = ((1 / 4) * BoundY)
' accumulator bouncer count
Form1.Caption = accumulator
If circlePosX < 1 Or circlePosY < 1 Then
accumulator = accumulator + 1
End If
If circlePosX > BoundX Or circlePosY > BoundY Then
accumulator = accumulator + 1
End If
'random number initiate for a wobble effect
'Dim RndMax As Long
'RndMax = 5 'Max value of ValRnd
'ValRnd = (Int(Rnd * RndMax) + 1)
' follow the bouncy ball
Line1.Y1 = Shape1.Top + (Shape1.Height / 2)
Line1.X1 = Shape1.Left + (Shape1.Width / 2)
Line1.Y2 = Shape2.Top + (Shape2.Height / 2)
Line1.X2 = Shape2.Left + (Shape2.Width / 2)
Line2.Y1 = Shape1.Top + (Shape1.Height / 2)
Line2.X1 = Shape1.Left + (Shape1.Width / 2)
Line2.Y2 = Shape3.Top + (Shape3.Height / 2)
Line2.X2 = Shape3.Left + (Shape3.Width / 2)
Line3.Y1 = Shape2.Top + (Shape2.Height / 2)
Line3.X1 = Shape2.Left + (Shape2.Width / 2)
Line3.Y2 = Shape3.Top + (Shape3.Height / 2)
Line3.X2 = Shape3.Left + (Shape3.Width / 2)
'x boundaries
If circlePosX < BoundX And isRight = True Then
circlePosX = circlePosX + 250 '* (ValRnd)
isRight = True
Else
circlePosX = circlePosX - 250 '* (ValRnd)
isRight = False
If circlePosX < 1 Then
isRight = True
End If
End If
'y boundaries
If circlePosY < BoundY And isDown = True Then
circlePosY = circlePosY + 250 '* (5 - ValRnd)
isDown = True
Else
circlePosY = circlePosY - 250 '* (5 - ValRnd)
isDown = False
If circlePosY < 1 Then
isDown = True
End If
End If
End Sub
an update to my original bounce program has bounce count, plots that follow the ball, start/stop bu Comments
No comments yet — be the first to post one!
Post a Comment