2 Pictureboxes disappear after 1 has been shot & shot continues upwards visible help!
Public Class Codified Dim RRight As Boolean 'Controls the Renegade's movement to the right' Dim RLeft As Boolean 'Controls the Renegade's movement to the left' Dim RenegadeSpeed As Integer 'Controls the Renegade's speed' Dim Shotspeed As Integer 'Controls the Shot speed' Private Sub Codified_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load loadsettings() 'loadsettings' End Sub Private Sub TimerMain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerMain.Tick MoveRenegade() 'movement of the renegade' FireShot() 'controls the movement of the shot' CheckHit() 'checks weather the guards have been hit' End Sub Private Sub Codified_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown 'this code moves the Renegade to the right' If e.KeyValue = Keys.Right Then RRight = True End If If e.KeyValue = Keys.Left Then RLeft = True RRight = False End If ' this code fires the shot' If e.KeyValue = Keys.Space And Shot.Visible = False Then Shot.Top = Renegade.Top Shot.Left = Renegade.Left + (Renegade.Width / 2) - (Shot.Width / 2) Shot.Visible = True End If End Sub Private Sub Codified_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp 'this code moves the Renegade left or right' If e.KeyValue = Keys.Right Then RRight = False End If If e.KeyValue = Keys.Left Then RLeft = False End If End Sub Private Sub MoveRenegade() 'this code moves the Renegade' If RRight = True And Renegade.Left + Renegade.Width < Me.ClientRectangle.Width Then Renegade.Left += RenegadeSpeed End If If RLeft = True And Renegade.Left > Me.ClientRectangle.Left Then Renegade.Left -= RenegadeSpeed End If End Sub Private Sub FireShot() 'this bit of code fires the shot' If Shot.Visible = True Then Shot.Top -= shotspeed End If If Shot.Top + Shot.Height < Me.ClientRectangle.Top Then Shot.Visible = False Shot.Left = 5000 End If End Sub Private Sub loadsettings() 'this loads all the setting on the form' shotspeed = 6 RenegadeSpeed = 6 Shot.Visible = False End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Guard1.Left = Guard1.Left + 3 'moves guard1 to the left' Guard2.Left = Guard2.Left - 4 'moves guard1 to the right' If Guard1.Left > 1400 Then 'restart point of guard1' Guard1.Left = -100 'restart point of guard1' End If If Guard2.Left < -1400 Then 'end point of guard2' Guard2.Left = 500 'restart point of guard2' End If End Sub Private Sub CheckHit() 'confirms that guard1 has been shot and restarts guard1' If Shot.Top < Guard1.Top + Guard1.Height And Shot.Left > Guard1.Left And Shot.Left < Guard1.Left + Guard1.Width Then Guard1.Visible = False LBLSCORE.Text = Val(LBLSCORE.Text) + 2 Guard1.Left = -100 Guard1.Visible = True End If 'confirms that guard2 has been shot and restarts guard2' If Shot.Top < Guard2.Top + Guard2.Height And Shot.Left > Guard2.Left And Shot.Left < Guard2.Left + Guard2.Width Then Guard2.Visible = False LBLSCORE.Text = Val(LBLSCORE.Text) + 2 Guard2.Left = -100 Guard2.Visible = True End If If LBLSCORE.Text = 10 Then TimerMain.Stop() 'stops the main timer' Timer1.Stop() 'stops timer 1' Me.Hide() 'hides main form after the mission has being accomplished' MsgBox("MISSION ACCOMPLISHED") ' displays message after set value has been met. End If End Sub