viernes, 4 de junio de 2010

Juego Imagenes

Juego Imagenes

En este programa hemos creado un juego de imágenes donde el usuario tendra que hacer parejas con las imagenes que sean iguales.
En el programa pondremos 16 imagenes y 16 picture box para tapar la imágenes cuando se inicie el programa, un progress bar para cargar el programa, tres label uno para el tiempo, uno para la puntación y un label para el tiempo del progress bar y finalmente ponemos los timers que correspondan a cada objeto.

En principio ponemos el progress bar y un label para su tiempo de carga.



Depués ponemos las 16 imagenes y los 16 picture box en el formulario, loslabels para cada cosa.



Despues ponemos el codigo correspondiente:

Dim x As Integer
Dim Contador As Integer
Dim i1 As Integer
Dim i2 As Integer
Dim tiempo As Integer

Private Sub Image2_Click()

End Sub

Private Sub Command1_Click()
Unload Me
Form1.Show
tiempo = 0
Contador = 0

End Sub

Private Sub Form_Load()

Image1(4).Picture = Image1(8).Picture
Image1(5).Picture = Image1(10).Picture
Image1(6).Picture = Image1(0).Picture
Image1(13).Picture = Image1(9).Picture
Image1(15).Picture = Image1(1).Picture
Image1(3).Picture = Image1(11).Picture
Image1(7).Picture = Image1(12).Picture
Image1(14).Picture = Image1(2).Picture

End Sub


Private Sub Menu1_Click()
Form2.Show 'muestra el form2
End Sub

Private Sub Menu2_Click()
If Lfecha.Visible = True Then 'pone el label visible
Lfecha.Visible = False 'pone el label no visible
Else
Lfecha.Visible = True 'pone el label visible
End If
If Lhora.Visible = True Then 'pone el label visible
Lhora.Visible = False 'pone el label no visible
Else

Lhora.Visible = True 'pone el label visible
End If

End Sub

Private Sub Menu3_Click()
End 'finaliza el programa
End Sub

Private Sub Picture1_Click(Index As Integer)
AC = 0

If Timer4.Enabled = True Then
If Image1(i1).Picture = Image1(Index).Picture Then
Label1.Caption = Label1.Caption + 1
Picture1(i1).Enabled = False
Picture1(Index).Enabled = False
Picture1(i1).Visible = False
Picture1(Index).Visible = False
Timer4.Enabled = False
AC = 1

Else
Picture1(i1).Visible = True
Timer4.Enabled = False
End If
End If
If AC = 0 Then
Picture1(Index).Visible = False
i1 = Index
Timer4.Enabled = True
End If
If Label1.Caption = 8 Then
Timer5.Enabled = False
End If
End Sub

Private Sub Timer1_Timer()

x = x + 1 'indica el valor de la variable
ProgressBar1.Value = x 'pone el valor del progressbar a x
If x >= 100 Then
x = 0
Timer1.Enabled = False 'indica que si x es 100 el timer este enable=false
End If
Picture1(x / 100 * 15).Visible = True
Image1(x / 100 * 15).Visible = True
If x >= 100 Then Timer1.Enabled = False

End Sub


Private Sub Timer2_Timer()

Contador = Contador + 1 'indica el valor de contador
Ltiempo.Caption = Contador ' idica el caption del timer
If ProgressBar1.Value = 100 Then 'indica el valor del value del progressbar a 100
Ltiempo.Caption = 100
ProgressBar1.Visible = False
Ltiempo.Visible = False
End If
End Sub

Private Sub Timer3_Timer()
Lfecha.Caption = Date 'muestra la fecha en el label
Lhora.Caption = Time 'muestra la hora en el label
End Sub

Private Sub Timer4_Timer()

Picture1(i1).Visible = True
Timer4.Enabled = False
End Sub

Private Sub Timer5_Timer()
If ProgressBar1.Value = 100 Then
tiempo = tiempo + 1
Label2.Caption = tiempo
End If
End Sub

Finalmente cambiamos la estetica del programa como por ejemplo ponemos un about, la hora y la fecha , cambiamos los colores de los picture box y ponemos un formulario de inicio de bienvenida.