Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Class Form1
- Dim playerAcceleration As Integer = 0
- Dim playerSpeed As Integer = 0
- Dim opponentAccelerations As New List(Of Integer)()
- Dim opponentSpeeds As New List(Of Integer)()
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Timer1.Interval = 50
- Timer1.Start()
- For i As Integer = 0 To 2
- opponentAccelerations.Add(0)
- opponentSpeeds.Add(0)
- Next
- End Sub
- Private Sub Form1_MouseClick(sender As Object, e As MouseEventArgs) Handles MyBase.MouseClick
- playerAcceleration += 5
- End Sub
- Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
- playerSpeed += playerAcceleration
- PictureBox1.Left += playerSpeed
- For i As Integer = 0 To 2
- opponentSpeeds(i) = CInt(Math.Floor((10 * Rnd()) + 1))
- opponentAccelerations(i) = 0
- Me.Controls("PictureBoxOpponent" & (i + 1)).Left += opponentSpeeds(i)
- If Me.Controls("PictureBoxOpponent" & (i + 1)).Right >= Me.ClientRectangle.Right Then
- Timer1.Stop()
- MessageBox.Show($"Opponent {i + 1} won!")
- Me.Close()
- End If
- Next
- If PictureBox1.Right >= Me.ClientRectangle.Right Then
- Timer1.Stop()
- MessageBox.Show("You won!")
- Me.Close()
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement