Mas vale tarde que nunca.... este es un clásico programa donde el programa elije un número y el usuario intenta descubrirlo con 10 posibilidades, el programa nos da la única pista que consiste en decir si el número que tenemos que descubrir es menor o mayor. Le agregue mas dificultad por medio de niveles el nivel 1 el programa elige entre 1 y 50, el nivel dos de 1 a 200, nivel 3 de 1 a 500, nivel 4 de 1 a 700 y el nivel mas difícil de 1 a mil.
Tiene una lista de usuarios que acertaron y los ordena de mayor a menor(bueno ese detalle todavía no lo resuelvo, espero que a ustedes se les ocurra una brillante idea y la compartan) donde los puntos se dan asi: 1000 porque juega en el nivel 5, 700 porque juega en el nivel 4 y asi sucesivamente, agregando a esas cifras el número de intentos que no se uso. Ejemplo: postapase juega en el nivel 5 y acierta en el primer intento son 10 puntos mas (1010), otro usuario juega en el nivel 3 y acierta en el 5 intento, los punto son 505 y así con lo demás. Bueno algo es algo
Fmain....
- código
- ' gambas class file
- Public espandir As Boolean = False
- Public offniveles As Boolean = True
- Public Nmagico As Float
- Public Ningresado As Integer
- Public intentos As Integer
- Public puntaje As Integer
- Public nomJugador As String
- Public Const N1 As Integer = 50
- Public Const N2 As Integer = 200
- Public Const N3 As Integer = 500
- Public Const N4 As Integer = 700
- Public Const N5 As Integer = 1000
- Public nivelelegido As Integer
- Public Sub Form_Open()
- Me.Center
- Me.Width = 210
- ValueBox1.Enabled = False
- nivelelegido = N1
- nivel1.Checked = True
- intentos = 10
- Labintentos.Visible = False
- offniveles = False
- End
- Public Function nivelesNO(offniveles As Boolean) As Boolean
- If offniveles = True Then
- nivel1.Enabled = False
- nivel2.Enabled = False
- nivel3.Enabled = False
- nivel4.Enabled = False
- nivel5.Enabled = False
- Else
- nivel1.Enabled = True
- nivel2.Enabled = True
- nivel3.Enabled = True
- nivel4.Enabled = True
- nivel5.Enabled = True
- Endif
- Return
- End
- Public Sub btnborrar_Click()
- ValueBox1.Value = 0
- ValueBox1.SetFocus
- End
- Public Sub btnVer_Click()
- Dim agrandar, achicar As Integer
- If espandir = True Then
- For achicar = 595 To 210 Step -1
- FMain.Width = achicar
- Wait 0.00049
- Next
- espandir = False
- btnVer.Text = "V\nE\nR\n" "\nR\nE\nC\nO\nR\nE\nS"
- Else
- For agrandar = 210 To 595 Step 1
- FMain.Width = agrandar
- Wait 0.00049
- Next
- espandir = True
- btnVer.Text = "O\nC\nU\nL\nT\nA\nR"
- Endif
- End
- Public Sub btnSalir_Click()
- Me.Close
- End
- Public Sub btnComenzar_Click()
- Dim achicar As Integer
- Labinfo.Text = ""
- Labintentos.Text = ""
- If espandir = True Then
- For achicar = 595 To 210 Step -1
- FMain.Width = achicar
- Wait 0.00049
- Next
- espandir = False
- btnVer.Text = "V\nE\nR\n" "\nR\nE\nC\nO\nR\nE\nS"
- usuario.Show
- Else
- btnVer.Enabled = False
- Labintentos.Caption = ""
- Labinfo.Caption = ""
- usuario.Show
- intentos = 10
- Randomize
- Nmagico = Int(Rnd(1, nivelelegido))
- ValueBox1.SetFocus
- Print Nmagico
- Print nivelelegido
- Endif
- End
- Public Sub btnIngresar_Click()
- Dim level As Integer
- If ValueBox1.Text = 0 Then
- Message.Info("El numero mínimo es 1")
- ValueBox1.Value = 1
- Else
- If ValueBox1.Text = Null Then
- Message.Info("ingrese un número para continuar")
- ValueBox1.Text = ""
- ValueBox1.SetFocus
- Return
- Else
- Labintentos.Caption = nomJugador & "\nTe quedan " & intentos & "\n restantes para adivinar\n el número Magico"
- Ningresado = ValueBox1.Text
- If Ningresado = " " Then
- Message.Info("Ingrese un numero")
- Else
- If intentos = 1 Then
- Labinfo.Caption = "Has perdido"
- Labintentos.Caption = nomJugador & "\n suerte para\n el próximo juego"
- ValueBox1.Text = 0
- btnborrar.Enabled = False
- btnIngresar.Enabled = False
- ValueBox1.Enabled = False
- btnComenzar.Enabled = True
- nivelesNO(False)
- Else
- If Ningresado > nivelelegido Then
- Select Case nivelelegido
- Case 50
- level = 1
- Case 200
- level = 2
- Case 500
- level = 3
- Case 700
- level = 4
- Case 1000
- level = 5
- End Select
- Message.Info("Esta jugando en nivel: " & level & "\n" & "eliga un número menor o igual a " & nivelelegido)
- ValueBox1.Text = ""
- ValueBox1.SetFocus
- Else
- If Ningresado >= 1001 Then
- Message.Info("Elija un número entre 1 y 1000")
- Else
- Select Case Ningresado
- Case Nmagico
- Labintentos.Caption = "FELICITACIONES \n HAS ACERTADO!!!"
- Labinfo.Caption = "GANASTE!!!"
- puntaje = nivelelegido + intentos
- ListBox1.Add(puntaje & " <nomJugador> Nmagico Then
- Labinfo.Caption = "numero menor"
- Dec intentos
- Labintentos.Caption = nomJugador & "\nTe quedan " & intentos & "\n restantes para adivinar\n el número Magico"
- Else
- Labinfo.Caption = "numero mayor"
- Dec intentos
- Labintentos.Caption = nomJugador & "\nTe quedan " & intentos & "\n restantes para adivinar\n el número Magico"
- Labintentos.Refresh
- Endif
- End Select
- Endif
- Endif
- Endif
- Endif
- Endif
- Endif
- Print intentos
- End
- Public Sub Form_KeyRelease() ' bueno al final solucione con este código, ya se que esta redesprolijo el programa pero...
- ' ta así nos salen las cosas a los novatos, la prolijidad de un programa viene con el tiempo y la experiencia
- If ValueBox1.Text > 1000 Then
- ValueBox1.Text = 0
- Else
- Return
- Endif
- End
usuario...
- ' gambas class file
- Public Sub btnAceptar_Click()
- If Txtnombre.Text = Null Then
- Message.Info("Ingrese su nombre para continuar")
- Return
- Else
- FMain.intentos = 10 ' agregue esta línea pues mostraba los intentos que restaban al jugador anterior :oops:
- FMain.btnborrar.Enabled = True
- FMain.Enabled = True
- FMain.nomJugador = UCase$(Txtnombre.Text)
- FMain.Labintentos.Visible = True
- FMain.Labintentos.Caption = FMain.nomJugador & "\nTe quedan " & FMain.intentos & "\n restantes para adivinar\n el número Magico"
- FMain.btnComenzar.Enabled = False
- FMain.offniveles = True
- FMain.nivelesNO(FMain.offniveles)
- Endif
- FMain.ValueBox1.Enabled = True
- FMain.ValueBox1.SetFocus
- FMain.btnIngresar.Enabled = True
- Me.Close
- End
- Public Sub Form_Open()
- FMain.Enabled = False
- Me.Center
- Me.Title = "Ingrese su nombre"
- End
- Public Sub btnCancelar_Click()
- Me.Close
- FMain.Enabled = True
- FMain.btnVer.Enabled = False
- End
info....
Código fuente: AdivinarNumero-0.0.1.tar.gz
Nota: tengo dos problemas
1. no se como limitar un valuebox a 4 dígitos
2. como ordenar números de mayor a menor en un listbox
estoy haciendo una tabla de record que es algo asi:
1000 si jugas en nivel 5
700 si jugas en nivel 4
500 si jugas en nivel 3
200 si jugas en nivel 2
50 si jugas en nivel 1
mas el factor intentos:
1 intentos= 10-1 (9)
2 intentos= 10-2 (8)
........
....
1010 <323> 06/09/2013
510 <MARIA> 06/09/2013
54 <CRISTINA> 06/09/2013 <----------- aquí esta mal aquí deberían ir los 60 despues los 59,58 etc... no se como ordenar aquí
56 <FABRICIO> 06/09/2013
57 <MARIANA> 06/09/2013
58 <CLAUDIA> 06/09/2013
58 <JULIANA> 06/09/2013
59 <FFF> 06/09/2013
59 <XXXXXXXXXXXXXXXX> 06/09/2013
60 <30> 06/09/2013
60 <45> 06/09/2013
60 <FFFFFFF> 06/09/2013
60 <HHHHHHHHHHHH> 06/09/2013
60 <JORGE> 06/09/2013
60 <LUCIA> 06/09/2013
60 <= ññññññññññññññññ => 06/09/2013
Le agregue una lista de los numeros ingresados,
guarda recores en un archivo *.lst
sigue con errores pero.... se lo dejo para que practiquen modificaciones o agregados
AdivinarNumero-0.0.2.tar.gz
.no se como anadir los ultimos item de un listbox a un archivo siemple de texto (ya resolví)
3.jajaja acepto sugerencias
4. saludos
AdivinarNumero-0.0.3.tar.gz