Hi,
With the assistance of another tutorial, I have managed to get a set row of aliens moving across the screen and then down and across the screen again, repeating this until they reach the bottom. However, I would like another row of aliens to do this as well but I can't seem to get them working. They are spawned on the screen just won't move.
Any assistance or help in doing this would be much appreciated. Below is code: Thanks
Dim numberofinvaders AsInteger = 11
Dim setofinvaders As Integer = 2
Dim invader(numberofinvaders) As PictureBox
Dim invadersspawned As Integer = 0
Dim alienmove As Integer = 5
Dim invaders As Integer = 5
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For column As Short = 0 To setofinvaders - 1
For lc = 1 To numberofinvaders
invadersspawned = invadersspawned + 1
invader(lc) = New PictureBox
invader(lc).Image = imginvader.Images(0)
invader(lc).Height = 16
invader(lc).Width = 16
invader(lc).Location = New System.Drawing.Point((lc * 22) + 10, 10 + column * 10)
Me.Controls.Add(invader(lc))
Next
Next
End Sub
Private Sub tmrInvader_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrInvader.Tick
For count = 1 To 11
invader(count).Left = invader(count).Left + invaders
Next count
If invader(11).Left + invader(11).Width > Me.Width - invader(11).Width Or invader(1).Left < 0 Then
invaders = -invaders
For count = 1 To 11
invader(count).Top = invader(count).Top + 10
Next
End If
EndSub
Thank you
With the assistance of another tutorial, I have managed to get a set row of aliens moving across the screen and then down and across the screen again, repeating this until they reach the bottom. However, I would like another row of aliens to do this as well but I can't seem to get them working. They are spawned on the screen just won't move.
Any assistance or help in doing this would be much appreciated. Below is code: Thanks
Dim numberofinvaders AsInteger = 11
Dim setofinvaders As Integer = 2
Dim invader(numberofinvaders) As PictureBox
Dim invadersspawned As Integer = 0
Dim alienmove As Integer = 5
Dim invaders As Integer = 5
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For column As Short = 0 To setofinvaders - 1
For lc = 1 To numberofinvaders
invadersspawned = invadersspawned + 1
invader(lc) = New PictureBox
invader(lc).Image = imginvader.Images(0)
invader(lc).Height = 16
invader(lc).Width = 16
invader(lc).Location = New System.Drawing.Point((lc * 22) + 10, 10 + column * 10)
Me.Controls.Add(invader(lc))
Next
Next
End Sub
Private Sub tmrInvader_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrInvader.Tick
For count = 1 To 11
invader(count).Left = invader(count).Left + invaders
Next count
If invader(11).Left + invader(11).Width > Me.Width - invader(11).Width Or invader(1).Left < 0 Then
invaders = -invaders
For count = 1 To 11
invader(count).Top = invader(count).Top + 10
Next
End If
EndSub
Thank you