juegos vb

25
JUEGOS REALIZADOS EN VISUAL BASIC 2011 PROGRAMACIÓN APLICADA PÁGINA 1

description

Programar facil

Transcript of juegos vb

Page 1: juegos vb

PROGRAMACIÓN APLICADA PÁGINA 1

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 2: juegos vb

TRABAJO DE PROGRAMACIÓN APLICADA

1. JUEGO TRAGAMONEDAS

1.1 Diagrama De Flujo Tragamonedas

PROGRAMACIÓN APLICADA PÁGINA 2

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 3: juegos vb

1.2 INSTALACIÓN:Para comenzar a disfrutar el juego, debemos instalar la aplicación tragamonedas en nuestro computador, encontramos el instalador en la carpeta ...\SetupTragamonedas\Debug de la aplicación, la cual instalamos para poder iniciar con el juego de tragamonedas en nuestro computador Elegimos la opción siguiente en todas las ventanas emergentes que aparezcan.

1.3 INICIO JUEGO:Luego de haber instalado el JUEGO de tragamonedas, lo ubicamos en INICIO-TODOS LOS PROGRAMAS-SETUPTRAGAMONEDAS o buscarla: “C:\Users\NombrePC\AppData\Roaming\Microsoft\Windows\StartMenu\Programs\JUEGOSVB\tragamonedas.exe”, para buscar la aplicación deseada del programa y poder ejecutar el juego. El juego inicia agregando saldo en un mensaje que es activado después de haber elegido la opción agregar saldo para posterior mente iniciar el juego.

PROGRAMACIÓN APLICADA PÁGINA 3

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 4: juegos vb

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAcumSal.Click 'Acumular saldo saldo = InputBox("Credito a depositar", "Casino UNC-SISTEMAS") Label3.Text = saldo If saldo > Nothing Then BtnAcumSal.Enabled = False BtnApostar.Enabled = True Label2.Text = "0" End If BtnSalir.Enabled = True End Sub

1.4 CARGANDO SALDOAparece un mensaje donde ingresamos la cantidad con la que vamos a jugar como vemos en la imagen. Una vez ingresado el saldo se activan las opciones jugar

1.4.1 CODIGO:

PROGRAMACIÓN APLICADA PÁGINA 4

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 5: juegos vb

1.5 APOSTARSe activara la opción Apostar luego de haber ingresado el saldo en la ventana emergente. En esta opción tenemos tres tipos de moneda con los cuales podemos apostar y jugar monedas de 1 de 2 y de 3 para tratar de lograr una jugada ganadora de acuerdo a la tabla de premios con la que se cuenta.

También se activa la opción salir en caso no se decida jugar y la cantidad apostada aumenta entre 1 y 3 mientras la cantidad disponible disminuye como vemos en la imagen.

PROGRAMACIÓN APLICADA PÁGINA 5

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 6: juegos vb

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnApostar.Click 'Apostar cantApostada = cantApostada + 1 saldo = CStr(CDbl(saldo) - 1) Label3.Text = CStr(saldo) Label2.Text = CStr(cantApostada) BtnJugar.Enabled = True If CDbl(saldo) = 0 Then BtnAcumSal.Enabled = True MsgBox("Agrega mas saldo o juega", MsgBoxStyle.Information, "Saldo agotado") BtnApostar.Enabled = False End If If cantApostada = 3 Then BtnApostar.Enabled = False End If BtnSalir.Enabled = False End Sub

1.5.1 CODIGO:

1.6 JUGARuna vez que se hace click en la opción jugar las imágenes giran y se generan aleatoriamente para dar inicio al juago si estas coinciden entonces se gana el monto que está establecido en la tabla de premios de acuerdo a la apuesta realizada. Este monto es agregado a la cantidad disponible para seguir jugando. También se activa un sonido del giro de las imágenes y de ganar cuando se gana o su defecto de perdida si se pierde

PROGRAMACIÓN APLICADA PÁGINA 6

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 7: juegos vb

Cuando se gana se activa la un mensaje que da aviso sobre el monto ganado; en la pantalla se muestra “Felicidades ganaste:” y el monto. Como vemos en la sgte. Imagen

PROGRAMACIÓN APLICADA PÁGINA 7

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 8: juegos vb

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnJugar.Click 'Jugar Label20.Text = "Buena Suerte" My.Computer.Audio.Play(Application.StartupPath + "\InicioJuego.wav") PictureBox1.Visible = True PictureBox2.Visible = True PictureBox3.Visible = True PictureBox15.Visible = False PictureBox16.Visible = False PictureBox17.Visible = False Timer2.Enabled = False Timer1.Enabled = True resultado() If CDbl(saldo) > 0 Then BtnApostar.Enabled = True 'activa boton apostar End If BtnJugar.Enabled = False 'desactiva Boton jugar cantApostada = 0 BtnSalir.Enabled = True ' Activar Boton salir End Sub

En el caso de no haber ganado la pantalla solo muestra la jugada y da la opción de seguir jugando.

1.6.1 CODIGO:

PROGRAMACIÓN APLICADA PÁGINA 8

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 9: juegos vb

1.7 SALIRSi se hace click en la opción salir se activa un mensaje si realmente se desea salir.

Si se elige si se activa un mensaje con la cantidad con la que se retira el jugador.

PROGRAMACIÓN APLICADA PÁGINA 9

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 10: juegos vb

Option Explicit OnOption Strict OnPublic Class SISTEMAS_UNC Dim saldo As String Dim saldo1 As Double Dim cantApostada, columna1, columna2, columna3, ganancia As Integer

Sub aleatorio() columna1 = 0

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSalir.Click 'Salir Dim result As DialogResult result = CType(MsgBox("¿Realmente deseas salir?", MsgBoxStyle.YesNo, "Salir"), Windows.Forms.DialogResult) If result = Windows.Forms.DialogResult.Yes Then If saldo > Nothing Then MsgBox("Te retiras con: " & saldo) Close() End If MsgBox("Suerte para la proxima") Close() End If End Sub

1.7.1 CÓDIGO

La otra parte del código parte del código se muestra de aquí para adelante:

PROGRAMACIÓN APLICADA PÁGINA 10

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 11: juegos vb

Option Explicit OnOption Strict OnPublic Class SISTEMAS_UNC Dim saldo As String Dim saldo1 As Double Dim cantApostada, columna1, columna2, columna3, ganancia As Integer

Sub aleatorio() columna1 = 0

Sub Primer_columna1() If columna1 = 1 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar.png") End If If columna1 = 2 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar bar.png") End If If columna1 = 3 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar bar bar.png") End If If columna1 = 4 Then PictureBox15.ImageLocation = Application.StartupPath & ("\7.png") End If If columna1 = 5 Then PictureBox15.ImageLocation = Application.StartupPath & ("\estrella.png") End If

End Sub Sub segunda_columna() If columna2 = 1 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar.png") End If If columna2 = 2 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar bar.png") End If If columna2 = 3 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar bar bar.png") End If If columna2 = 4 Then PictureBox16.ImageLocation = Application.StartupPath + ("\7.png") End If If columna2 = 5 Then PictureBox16.ImageLocation = Application.StartupPath + ("\estrella.png") End If End Sub Sub Tercer_columna() If columna3 = 1 Then PictureBox17.Load(Application.StartupPath + "\bar.png") End If If columna3 = 2 Then PictureBox17.Load(Application.StartupPath + "\bar bar.png") End If If columna3 = 3 Then PictureBox17.Load(Application.StartupPath + "\bar bar bar.png") End If If columna3 = 4 Then

Esta parte del código es para cargar las imágenes que hay en el tragamonedas:

PROGRAMACIÓN APLICADA PÁGINA 11

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 12: juegos vb

Sub Primer_columna1() If columna1 = 1 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar.png") End If If columna1 = 2 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar bar.png") End If If columna1 = 3 Then PictureBox15.ImageLocation = Application.StartupPath & ("\bar bar bar.png") End If If columna1 = 4 Then PictureBox15.ImageLocation = Application.StartupPath & ("\7.png") End If If columna1 = 5 Then PictureBox15.ImageLocation = Application.StartupPath & ("\estrella.png") End If

End Sub Sub segunda_columna() If columna2 = 1 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar.png") End If If columna2 = 2 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar bar.png") End If If columna2 = 3 Then PictureBox16.ImageLocation = Application.StartupPath + ("\bar bar bar.png") End If If columna2 = 4 Then PictureBox16.ImageLocation = Application.StartupPath + ("\7.png") End If If columna2 = 5 Then PictureBox16.ImageLocation = Application.StartupPath + ("\estrella.png") End If End Sub Sub Tercer_columna() If columna3 = 1 Then PictureBox17.Load(Application.StartupPath + "\bar.png") End If If columna3 = 2 Then PictureBox17.Load(Application.StartupPath + "\bar bar.png") End If If columna3 = 3 Then PictureBox17.Load(Application.StartupPath + "\bar bar bar.png") End If If columna3 = 4 Then

Continuamos con la parte donde carga los resultados

PROGRAMACIÓN APLICADA PÁGINA 12

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 13: juegos vb

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick PictureBox15.Visible = True PictureBox16.Visible = True PictureBox17.Visible = True PictureBox1.Visible = False PictureBox2.Visible = False PictureBox3.Visible = False Primer_columna1() segunda_columna() Tercer_columna() Timer2.Enabled = True If columna1 <> columna2 Or columna1 <> columna3 Or columna2 <> columna3 Then My.Computer.Audio.Play(Application.StartupPath + "\NOTIEMPO.wav") Label2.Text = "0" End If If columna1 = columna2 And columna2 = columna3 And columna1 = columna3 Then My.Computer.Audio.Play(Application.StartupPath + "\CASH2.wav") MessageBox.Show("Has ganado") End If End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Timer1.Enabled = False End Sub

Código para timers

PROGRAMACIÓN APLICADA PÁGINA 13

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 14: juegos vb

2. JUEGO DE MEMORIA

2.1 Diagrama De Flujo Memoria

PROGRAMACIÓN APLICADA PÁGINA 14

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 15: juegos vb

2.2 INSTALACIÓN:Para comenzar a disfrutar el juego, debemos instalar la aplicación tragamonedas en

nuestro computador, encontramos el instalador en la carpeta ...\SetupMemoria\Debug de la aplicación, la cual instalamos para poder iniciar con el juego de Memoria en nuestro computador Elegimos la opción siguiente en todas las ventanas emergentes que aparezcan.

2.3 INICIO JUEGO:Luego de haber instalado el JUEGO de tragamonedas, lo ubicamos en INICIO-TODOS LOS PROGRAMAS-SETUPTRAGAMONEDAS o buscarla: “C:\Users\NombrePC\AppData\Roaming\Microsoft\Windows\StartMenu\Programs\memoria.exe”, para buscar la aplicación deseada del programa y poder ejecutar el juego. El juego inicia eligiendo uno de los niveles mostrados en la imagen siguiente.

PROGRAMACIÓN APLICADA PÁGINA 15

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 16: juegos vb

2.4 ELECCIÓN NIVELAl seleccionar el nivel se activan o desactivan cuadros de texto

2.5 JUGARuna vez que se hace click en la opción jugar se activa las letras que se deben escribir en las cuadros de texto esta opción solo estará activada por un pequeño tiempo .

PROGRAMACIÓN APLICADA PÁGINA 16

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 17: juegos vb

una vez escritas las palabras en los cuadros de texto se presiona listo para ver si se ganó o perdió

Si se gana y se escribe a tiempo se muestra un mensaje en la pantalla indicando que se gano

PROGRAMACIÓN APLICADA PÁGINA 17

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 18: juegos vb

Si se demora mucho en escribir sale un mensaje indicando la demora

PROGRAMACIÓN APLICADA PÁGINA 18

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 19: juegos vb

Si se escribe mal las letras en los cuadros de texto se muestra el siguiente mensaje

2.6 SALIRPara salir se hace click en cerrar de al aplicación

PROGRAMACIÓN APLICADA PÁGINA 19

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 20: juegos vb

Public Class Memoria Dim a, b As Short Dim cont As Short Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = " juego Memoria " + Now.ToShortDateString + " " + Now.ToShortTimeString a = 0 b = 0 cont = 0 End Sub Private Sub fin()

'btnJugar.Enabled = False

2.7 CODIGO:

PROGRAMACIÓN APLICADA PÁGINA 20

2011JUEGOS REALIZADOS EN VISUAL BASIC

Page 21: juegos vb

Public Class Memoria Dim a, b As Short Dim cont As Short Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Text = " juego Memoria " + Now.ToShortDateString + " " + Now.ToShortTimeString a = 0 b = 0 cont = 0 End Sub Private Sub fin()

'btnJugar.Enabled = False

Private Sub rbnbasico_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbnbasico.CheckedChanged cont = 3 btnJugar.Enabled = True TextBox4.Visible = False TextBox5.Visible = False TextBox6.Visible = False TextBox7.Visible = False lblletras.Text = "" btnJugar.Focus() fin() End Sub Private Sub rbnintermedio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbnintermedio.CheckedChanged cont = 5 fin() lblletras.Text = "" btnJugar.Enabled = True TextBox4.Visible = True TextBox5.Visible = True TextBox6.Visible = False TextBox7.Visible = False End Sub Private Sub rbnavanzado_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbnavanzado.CheckedChanged cont = 7 fin() lblletras.Text = "" btnJugar.Enabled = True TextBox4.Visible = True TextBox5.Visible = True TextBox6.Visible = True TextBox7.Visible = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick a = a + 10 If rbnbasico.Checked = True Then If a = 700 Then MessageBox.Show("Te demorastes mucho, intenta de nuevo") fin() Timer1.Enabled = False a = 0

If rbnavanzado.Checked = True Then If a = 1500 Then MessageBox.Show("Te demorastes mucho, intenta de nuevo") fin() Timer1.Enabled = False a = 0 b = 0 cont = 0 btnJugar.Enabled = False End If End If End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick b = b + 10 If rbnbasico.Checked = True Then If b = 200 Then lblletras.Visible = False End If End If If rbnintermedio.Checked = True Then If b = 400 Then lblletras.Visible = False End If End If If rbnavanzado.Checked = True Then If b = 800 Then lblletras.Visible = False End If End If End Sub Private Sub btnJugar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnJugar.Click Dim i, y As Short Dim x As System.Random x = New System.Random For i = 1 To cont y = x.Next(65, 91) lblletras.Text = lblletras.Text & Chr(y)

PrivateSystem.EventArgs) Trim(TextBox3.Text.ToUpper) & Trim(TextBox4.Text.ToUpper) & Trim(TextBox5.Text.ToUpper) & Trim(TextBox6.Text.ToUpper) & Trim(TextBox7.Text.ToUpper) End

PROGRAMACIÓN APLICADA PÁGINA 21

2011JUEGOS REALIZADOS EN VISUAL BASIC