This is my code for the firing
Dim positionint = 1
' for when a key on the keyboard
Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
' Sets Handled to true to prevent other controls from
' receiving the key if an arrow key was pressed
Dim bHandled As Boolean = False
Select Case e.KeyCode
Case Keys.Right
positionint -= 1
e.Handled = True
Case Keys.Left
positionint += 1
e.Handled = True
Case Keys.Space
bullet.Size = New Point(10, 10)
bullet.Visible = True
bullet.BackColor = Color.Blue
CentreOn(Car, bullet)
Me.Controls.Add(bullet)
bullet.Visible = True
Bullettmr.Start()
Case Keys.Z
mutiplebullets()
End Select
If positionint = 0 Then
Car.Location = New Point(p1.Location.X, Car.Location.Y)
positionint += 1
End If
If positionint = 1 Then
Car.Location = New Point(p1.Location.X, Car.Location.Y)
End If
If positionint = 2 Then
Car.Location = New Point(p2.Location.X, Car.Location.Y)
End If
If positionint = 3 Then
Car.Location = New Point(p3.Location.X, Car.Location.Y)
End If
If positionint = 4 Then
Car.Location = New Point(p4.Location.X, Car.Location.Y)
End If
If positionint = 5 Then
Car.Location = New Point(p5.Location.X, Car.Location.Y)
End If
If positionint = 6 Then
Car.Location = New Point(p6.Location.X, Car.Location.Y)
End If
If positionint = 7 Then
Car.Location = New Point(p7.Location.X, Car.Location.Y)
End If
If positionint = 8 Then
Car.Location = New Point(p8.Location.X, Car.Location.Y)
positionint -= 1
End If
End Sub
We Are Constrating on the Z on the key down
now the timer code
Private Sub rockettmr_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rockettmr.Tick
rocketnumber += 1
rocket.Location = New Point(rocketnumber, rocket.Location - 20)
End Sub
now the sub code
Dim rocketnumber As Integer = 0
Public Sub mutiplebullets()
Dim rocket As New PictureBox
rocket.Name = "therocket" + rocketnumber.ToString
rocket.Size = New Point(10, 10)
rocket.Visible = True
rocket.BackColor = Color.Green
CentreOn(Car, rocket)
Me.Controls.Add(rocket)
rockettmr.Start()
End Sub
Whats meant to happen is that I press Z and a bullet should fire, but I can't seem to do that, the bullet doesn't move. and i also neeed to access the sub so when the bullet hits another picturebox somthing will happen