Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit Off
- Public Class Form1
- Dim conteo As Integer = 90
- Dim conteo2 As Integer = 420
- Dim misil As New PictureBox
- Dim fuerza As Integer = 1
- Dim esfuerz As Integer = 1
- Dim impulso As Integer = 1
- Dim random As New Random
- Dim objetivo(2) As Integer
- Dim viento1 As New Random
- Dim viento2 As New Random
- Dim impulso2 As Integer = 1
- Dim mivientorandom As New Random
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If TextBox1.Text.Trim.Length = 0 Then
- MessageBox.Show("Debe elegir la carga de TNT (de 1 a 200)", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information)
- Exit Sub
- End If
- If Val(TextBox1.Text) <= 0 Or Val(TextBox1.Text) > 200 Then
- MessageBox.Show("El valor de la carga de TNT debe ser entre 1 y 200", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Information)
- TextBox1.Focus()
- Exit Sub
- End If
- Button1.Enabled = False
- My.Computer.Audio.Play(My.Resources.disparo, AudioPlayMode.Background)
- My.Settings.perdidas = My.Settings.perdidas + 1
- My.Settings.Save()
- 'creo el misil
- misil.Width = 20
- misil.Height = 20
- misil.BackColor = Color.White
- misil.Image = ImageList1.Images(0)
- misil.SizeMode = PictureBoxSizeMode.StretchImage
- misil.Location = New Point(90, 420)
- Me.Controls.Add(misil)
- 'disparo
- Timer1.Enabled = True
- fuerza = 420 - TextBox1.Text
- impulso = TextBox2.Text
- 'selecciono y aplico el impulso
- Select Case ComboBox1.Text
- Case "Suave"
- impulso2 = 1
- Case "Mediano"
- impulso2 = 3
- Case "Fuerte"
- impulso2 = 6
- End Select
- Timer5.Enabled = True
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Timer1.Interval = impulso * 10
- conteo = conteo + impulso2
- conteo2 = conteo2 - 1
- If conteo2.ToString.Contains("5") Or conteo2.ToString.Contains("2") Then
- conteo = conteo + 3
- End If
- misil.Location = New Point(conteo, conteo2)
- fuerza = 420 - TextBox1.Text
- impulso = TextBox2.Text
- If misil.Location.Y < fuerza Then
- 'desciende el misil
- Timer1.Enabled = False
- Timer2.Enabled = True
- End If
- End Sub
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- Timer1.Interval = impulso
- conteo = conteo + 1
- conteo2 = conteo2 + 1
- If conteo.ToString.Contains("5") Or conteo.ToString.Contains("2") Then
- conteo = conteo + 8
- End If
- If conteo.ToString.Contains("5") Or conteo.ToString.Contains("2") Then
- conteo2 = conteo2 + 7
- End If
- misil.Location = New Point(conteo, conteo2)
- End Sub
- Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
- My.Settings.Save()
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'muestro las partidas ganadas y perdidas
- Label11.Text = My.Settings.ganadas
- Label12.Text = My.Settings.perdidas - My.Settings.ganadas
- 'posiciono el enemigo
- Me.SetStyle(ControlStyles.DoubleBuffer Or ControlStyles.AllPaintingInWmPaint, True)
- pos = random.Next(500, 1000)
- PictureBox2.Location = New Point(pos, 387)
- objetivo(0) = PictureBox2.Location.X
- objetivo(1) = PictureBox2.Location.Y
- 'establezco la intensidad del viento
- unidad = mivientorandom.Next(1, 10)
- TextBox2.Text = unidad
- Label5.Text = unidad.ToString
- 'calculo la distancia del objetivo (inicial)
- inicial = PictureBox2.Location.X - 32
- Label7.Text = inicial.ToString
- End Sub
- Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
- 'calculo si hizo impacto
- If misil.Location.X >= PictureBox2.Location.X And misil.Location.X <= PictureBox2.Location.X + 84 + 84 And misil.Location.Y >= 387 And misil.Location.Y <= 387 + 50 Or misil.Location.X + 20 >= PictureBox2.Location.X And misil.Location.X + 20 <= PictureBox2.Location.X + 84 And misil.Location.Y >= 387 And misil.Location.Y <= 387 + 50 Then
- Label3.Text = "acerto!!!"
- My.Settings.ganadas = My.Settings.ganadas + 1
- My.Settings.Save()
- Timer1.Enabled = False
- Timer2.Enabled = False
- Timer4.Enabled = False
- PictureBox2.Visible = False
- PictureBox3.Location = New Point(PictureBox2.Location.X, PictureBox2.Location.Y - 35)
- PictureBox3.Visible = True
- misil.Visible = False
- My.Computer.Audio.Play(My.Resources.superbomba, AudioPlayMode.Background)
- Label11.Text = CInt(Label11.Text + 1).ToString
- Exit Sub
- End If
- End Sub
- Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
- 'con esto mido la distancia entre el misil y el objetivo y la muestro
- mipunta = misil.Location.X + 20
- mipuntaobjetivo = PictureBox2.Location.X
- midistancia = mipuntaobjetivo - mipunta
- Label7.Text = midistancia.ToString + " Metros"
- If midistancia <= 0 Then
- Label7.Text = "0 Metros"
- End If
- If misil.Location.Y > 465 Then
- Label7.Text = "0 metros"
- End If
- If misil.Location.X > 1181 Then
- Label7.Text = "0 metros"
- End If
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- 'vuelvo a ejecutar el software para resetear los datos
- miruta = My.Application.Info.DirectoryPath + "\juego.exe"
- System.Diagnostics.Process.Start(miruta)
- End
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- 'reseteo los contadores de las partidas ganadas y perdidas
- If MessageBox.Show("Esta seguro de que desea borrar los contadores?", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
- My.Settings.ganadas = 0
- My.Settings.perdidas = 0
- My.Settings.Save()
- Label11.Text = "0"
- Label12.Text = "0"
- miruta = My.Application.Info.DirectoryPath + "\juego.exe"
- System.Diagnostics.Process.Start(miruta)
- End
- End If
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement