Dim invader(6) As PictureBox
Dim invaderlife(30) As Boolean
Dim PicInvaderlife1 As Boolean = True
Dim PicInvaderlife2 As Boolean = True
Dim PicInvaderlife3 As Boolean = True
Dim PicInvaderlife4 As Boolean = True
Dim PicInvaderlife5 As Boolean = True
Dim PicInvaderlife6 As Boolean = True
Dim invaderleft As Integer = 5
Dim border(6) As PictureBox
Dim invadercount As String = 6
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Picbullet.Location = New System.Drawing.Point(PicSpaceship.Left + (PicSpaceship.Width / 2), PicSpaceship.Top)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
My.Computer.Audio.Play("H:\Unit 12 -Software Development (Games)\Space invaders game tutorial\Teminite & MDK - Space Invaders.wav", AudioPlayMode.BackgroundLoop)
InstructionsPNL.Visible = False
Splashscreen_timer.Start()
#Region "Spaceship&bullet Intersects with border"
Private Sub spaceship_timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles spaceship_timer.Tick
PicSpaceship.Left += Left_right_mover
If PicSpaceship.Bounds.IntersectsWith(border(Moves).Bounds) Then
PicSpaceship.Left -= Left_right_mover
If Picbullet.Bounds.IntersectsWith(border(3).Bounds) Then
If Picbullet.Bounds.IntersectsWith(border(4).Bounds) Then
If Picbullet.Bounds.IntersectsWith(border(5).Bounds) Then
If Picbullet.Bounds.IntersectsWith(border(6).Bounds) Then
#Region "Shoot down the alien"
Private Sub bullet_timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bullet_timer.Tick
If Picbullet.Top <= 5 Then
If Picbullet.Bounds.IntersectsWith(PicAlien1.Bounds) Then
PicAlien1.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
If Picbullet.Bounds.IntersectsWith(PicAlien2.Bounds) Then
PicAlien2.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
If Picbullet.Bounds.IntersectsWith(PicAlien3.Bounds) Then
PicAlien3.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
If Picbullet.Bounds.IntersectsWith(PicAlien4.Bounds) Then
PicAlien4.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
If Picbullet.Bounds.IntersectsWith(PicAlien5.Bounds) Then
PicAlien5.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
If Picbullet.Bounds.IntersectsWith(PicAlien6.Bounds) Then
PicAlien6.Location = New System.Drawing.Point(12, 500)
Convert.ToInt16(invadercount)
invadercount = invadercount - 1
Convert.ToString(invadercount)
invadercountLBL.Text = "invaderleft: " + invadercount
Private Sub Alien_timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Alien_timer.Tick
PicAlien1.Left = PicAlien1.Left + invaderleft
PicAlien2.Left = PicAlien2.Left + invaderleft
PicAlien3.Left = PicAlien3.Left + invaderleft
PicAlien4.Left = PicAlien4.Left + invaderleft
PicAlien5.Left = PicAlien5.Left + invaderleft
PicAlien6.Left = PicAlien6.Left + invaderleft
If PicAlien1.Left >= 810 Then invaderleft *= -1
If PicAlien2.Left >= 810 Then invaderleft *= -1
If PicAlien3.Left >= 810 Then invaderleft *= -1
If PicAlien4.Left >= 810 Then invaderleft *= -1
If PicAlien5.Left >= 810 Then invaderleft *= -1
If PicAlien6.Left >= 810 Then invaderleft *= -1
If PicAlien1.Left <= 10 Then invaderleft *= -1
If PicAlien2.Left <= 10 Then invaderleft *= -1
If PicAlien3.Left <= 10 Then invaderleft *= -1
If PicAlien4.Left <= 10 Then invaderleft *= -1
If PicAlien5.Left <= 10 Then invaderleft *= -1
If PicAlien6.Left <= 10 Then invaderleft *= -1
invader(j).Left += leftmove
If invader(j).Left > 1000 Then
If invader(j).Left < 10 Then
#Region "Panels and buttons"
Private Sub Start_Game_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start_GameBtn.Click
InstructionsPNL.Visible = False
Private Sub Close_me_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Close_meBtn.Click
Private Sub InstructionsBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InstructionsBtn.Click
GamePanel.Visible = False
InstructionsPNL.Visible = True
Private Sub BacktomenuBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BacktomenuBTN.Click
InstructionsPNL.Visible = False
Private Sub QuitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles QuitToolStripMenuItem.Click
Private Sub InstructionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InstructionsToolStripMenuItem.Click
MsgBox(" Instructions!" & vbCrLf & " " & vbCrLf & "Move your spaceship Left and Right using the arrow keys." & vbCrLf & "Fire your gun by using the Left shift key to shoot aliens." & vbCrLf & "The game will finish, If you kill all Aliens." & vbCrLf & "If you want to mute the music go to the Instructions Panel" & vbCrLf & "Press 'p/P' If you want to Pause the game." & vbCrLf & "Press i/I for instructions")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MutesoundsBTN.Click
Private Sub SoundonBTN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SoundonBTN.Click
My.Computer.Audio.Play("H:\Unit 12 -Software Development (Games)\Space invaders game tutorial\Teminite & MDK - Space Invaders.wav", AudioPlayMode.BackgroundLoop)
Private Sub SoundOffToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SoundOffToolStripMenuItem.Click
Private Sub SoundOnToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SoundOnToolStripMenuItem.Click
My.Computer.Audio.Play("H:\Unit 12 -Software Development (Games)\Space invaders game tutorial\Teminite & MDK - Space Invaders.wav", AudioPlayMode.BackgroundLoop)
Private Sub PauseToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PauseToolStripMenuItem.Click
Alien_timer.Enabled = False
bullet_timer.Enabled = False
spaceship_timer.Enabled = False
MsgBox("You Paused the game")
Private Sub Splashscreen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Splashscreen_timer.Tick
If LoadingBar.Value = 8000 Then
Splashscreen_timer.Enabled = False
Private Sub Form1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
Alien_timer.Enabled = True
bullet_timer.Enabled = True
spaceship_timer.Enabled = True
Alien_timer.Enabled = False
bullet_timer.Enabled = False
spaceship_timer.Enabled = False
MsgBox("You Paused the game")
Alien_timer.Enabled = True
bullet_timer.Enabled = True
spaceship_timer.Enabled = True
Alien_timer.Enabled = False
bullet_timer.Enabled = False
spaceship_timer.Enabled = False
MsgBox("You Paused the game")
MsgBox(" Instructions!" & vbCrLf & " " & vbCrLf & "Move your spaceship Left and Right using the arrow keys." & vbCrLf & "Fire your gun by using the Left shift key to shoot aliens." & vbCrLf & "The game will finish, If you kill all Aliens." & vbCrLf & "If you want to mute the music go to the Instructions Panel" & vbCrLf & "Press 'p/P' If you want to Pause the game." & vbCrLf & "Press i/I for instructions")
MsgBox(" Instructions!" & vbCrLf & " " & vbCrLf & "Move your spaceship Left and Right using the arrow keys." & vbCrLf & "Fire your gun by using the Left shift key to shoot aliens." & vbCrLf & "The game will finish, If you kill all Aliens." & vbCrLf & "If you want to mute the music go to the Instructions Panel" & vbCrLf & "Press 'p/P' If you want to Pause the game." & vbCrLf & "Press i/I for instructions")
Private Sub LoadSettings()