⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 principal.class

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 CLASS
字号:
' Gambas class PUBLIC boton AS Button 'object variable for charge buttons on ejecution timePUBLIC sonido AS Sound 'objeto que permite lanzar los sonidos(Play the Sounds)PUBLIC aplauso AS Sound 'Sonido de aplauso cuando se acierta en un par de caritas (Applause Sound at each movement)PUBLIC botones AS Object[] 'Arreglo de botones del tablero de juego (Buttons array for game board)PUBLIC botones_foticos AS Object[] 'Arreglo de botones con las figuritas (Buttons array with images loaded)                                   'en el form fotos'variables del juegoPUBLIC tam_tablero AS Integer 'para conocer en todo momento cual es el tamaño del tablero (filas y columnas)                              'It is for know in all moment the boad size(row and columns)PUBLIC habilitar AS Boolean 'para establecer si el jugador puede empezar a descubrir los botoncitos                            'Stablish if player can move PRIVATE anterior_boton_jugado AS Integer 'se utiliza para recordar el numero del ultimo boton pulsado, a fin de poder                                       'restaurarlo, en el caso del primer movimiento de una jugada, cuando no hay coincidencia                                       'de las imagenes destapadas  (remember last pushed button)                                       'Las siguientes dos variables fueron necesarias a fin de preservar la informacion contenida en la variable anterior_boton_jugado 'y en LAST.tag durante la ejecucion del evento click sobre los botones, esto debido a que la ejecucion de codigo no se 'interrumpe con la activacion del timer, de esta forma se permite un retardo en la visualizacion de pares de botones descubiertos'para que el jugador pueda reconocer la figura oculta en caso de que ambos dibujos no coincidan'...............................................................................................'Next variables would be needed for save information in variable anterior_boton_jugado and LAST.tag (for grupo_botones group)'for click event, it is for permit a delay in each movement, so the player can visualize every faces.PRIVATE boton_actual_paratimer AS IntegerPRIVATE boton_ultimo_paratimer AS Integer'FUNCIONALIDAD AÑADIDA DE ACCESO A BASE DE DATOS PARA ALMACENAR LOS DATOS DEL'JUEGO, MEJORES PUNTAJES POR CATEGORIA'PRIVATE myarchivo AS File'PRIVATE mylinea AS String'Variable para almacenar el idioma en uso'........................................'Capture and almacenate the language in usePUBLIC language AS StringPUBLIC SUB Form_Open()DIM i AS IntegerRandomize sonido = NEW Sound("Wallhit.wav") 'Instancia del objeto sonido  - Sound object instanceaplauso = NEW sound("applause.wav")   'IF NOT Access(system.Home &/"myarchivo.ini") THEN    '   message ("no existe")   '   OPEN system.Home &/"myarchivo.ini" FOR CREATE AS myarchivo   '     'WHILE NOT Eof(myarchivo)   '        'LINE INPUT #myarchivo, mylinea   '        'message (mylinea)   '     'WEND   '   myarchivo.Save("hola")        '        '   CLOSE myarchivo  'END IF'Se crea el array de objetos botones, esto con el fin de facilitar la manipulacion'de eventos comunes a un grupo de botones.'..................................................................................'Create the buttons to be used for next gamebotones= NEW Object[] 'Array of buttonsFOR i=1 TO 64  boton= NEW Button(ME) AS "grupobotones"  boton.tag=i-1  'The button object array is created, it is for manipulate the common events to group buttons  botones.Add(boton) 'NEXT    'Se crea este arreglo para tomar referencia de las foticos de los botones  'en el form fotos  '..........................................................................  'This array contain a reference for images to visualice in the game  botones_foticos=NEW Object[]  botones_foticos.Add(fotos.Button1)  botones_foticos.Add(fotos.Button2)  botones_foticos.Add(fotos.Button3)  botones_foticos.Add(fotos.Button4)  botones_foticos.Add(fotos.Button5)  botones_foticos.Add(fotos.Button6)  botones_foticos.Add(fotos.Button7)  botones_foticos.Add(fotos.Button8)  botones_foticos.Add(fotos.Button9)  botones_foticos.Add(fotos.Button10)  botones_foticos.Add(fotos.Button11)  botones_foticos.Add(fotos.Button12)  botones_foticos.Add(fotos.Button13)  botones_foticos.Add(fotos.Button14)  botones_foticos.Add(fotos.Button15)  botones_foticos.Add(fotos.Button16)  botones_foticos.Add(fotos.Button17)  botones_foticos.Add(fotos.Button18)  botones_foticos.Add(fotos.Button19)  botones_foticos.Add(fotos.Button20)  botones_foticos.Add(fotos.Button21)  botones_foticos.Add(fotos.Button22)  botones_foticos.Add(fotos.Button23)  botones_foticos.Add(fotos.Button24)  botones_foticos.Add(fotos.Button25)  botones_foticos.Add(fotos.Button26)  botones_foticos.Add(fotos.Button27)  botones_foticos.Add(fotos.Button28)  botones_foticos.Add(fotos.Button29)  botones_foticos.Add(fotos.Button30)  botones_foticos.Add(fotos.Button31)  botones_foticos.Add(fotos.Button32)  botones_foticos.Add(fotos.Button33)  botones_foticos.Add(fotos.Button34)  botones_foticos.Add(fotos.Button35)  botones_foticos.Add(fotos.Button36)  botones_foticos.Add(fotos.Button37)  botones_foticos.Add(fotos.Button38)  botones_foticos.Add(fotos.Button39)  botones_foticos.Add(fotos.Button40)'Pensaba permitir al usuario normal el cambio de las imagenes de los'botoncitos pero, parece mejor que el usuario que quiera modificar estos'dibujos, lo haga en el proyecto fuente'.......................................................................'Maybe is possible permit to user manipulate the images, but for now it is'done only by codetam_tablero=4funciones.distrib(tam_tablero, 45)ENDPUBLIC SUB grupobotones_Click()      DIM jugada_valida AS Boolean   DIM continuar AS Boolean      'message(LAST.tag)      continuar=TRUE   'Se verifica si el tablero acepta jugadas, es decir si el juego esta en curso   '............................................................................   'Verify if board is active for game   IF ME.habilitar=TRUE THEN     'Antes que nada se comprueba que el boton pulsado no se haya jugado antes     'utilizo el atributo btnInicial.picture porque resulta sencillo comparar de esta forma si el cuadrito ya no tiene      'el dibujo del signo de interrogacion     '............................................................................     'Comprobe is current pushed button haven't been discovered.     IF (LAST.picture <> ME.btnInicial.picture) THEN       'Ojo, si el boton pulsado ya habia sido descubierto durante el primer movimiento de esta jugada       '...............................................................................................       'Inhabilite the movement for a button when it have been discovered.       continuar=FALSE       message("Jugada Errada")            END IF                   IF continuar THEN                    sonar(1)                             LAST.picture=ME.botones_foticos[funciones.devolver_indice_defotico(LAST.tag)].picture              IF funciones.num_movimiento_actual=1 THEN 'Se esta haciendo el segundo movimiento de una jugada                            'Se debe comparar la imagen, para saber si hubo coincidencia              '............................................................              'Compare the imagen for stablish if movement is correct              jugada_valida=funciones.comparar_botones_jugados(anterior_boton_jugado, LAST.tag)                            'Se aumenta el contador de jugadas (cada jugada corresponde a 2 movimientos), se actualiza el label              '..................................................................................................              'Increase the play counter (each turne have two movements), label is refresh              funciones.jugadas=funciones.jugadas+1               ME.lblJugadas.Caption=funciones.jugadas                              IF jugada_valida THEN                 sonar(2)                 'depuracion                 'ME.botones[LAST.tag].enabled=FALSE                 'ME.botones[anterior_boton_jugado].enabled=FALSE                                  funciones.aciertos=funciones.aciertos+1 'El jugador tuvo un acierto mas (player have acerted)                 'se verifica si el numero de aciertos indica el fin del juego, en todo caso el numero de aciertos para                 'finalizar el juego debe ser igual a pow(tam_tablero,2)/2, por ejemplo si el jugador escogio el nivel                 'experto, el tamaño del tablero sera de 8*8, entonces los aciertos necesarios para finalizar el juego son:                 '64/2=32                 '...................................................................................................                 'Verify numbers of acerts, for stablish the game end, for end the game acerts maybe be equal to                 'pow(tam_tablero,2)/2                 IF funciones.aciertos = ME.tam_tablero*ME.tam_tablero/2 THEN                   timer2.Enabled=FALSE 'se termina el conteo de tiempo                                      message.Info("Felicitaciones, has cumplido la mision")                                    END IF               ELSE                                  habilitar=FALSE                   boton_actual_paratimer=LAST.tag                 boton_ultimo_paratimer=anterior_boton_jugado                                  timer1.enabled=TRUE                                                                  END IF                          END IF                          funciones.num_movimiento_actual=funciones.num_movimiento_actual + 1 'Se ha hecho un movimiento            'message(ultimo_boton_jugado)             anterior_boton_jugado=LAST.tag                IF funciones.num_movimiento_actual=2 THEN              funciones.num_movimiento_actual=0 'Si se hizo el segundo movimiento, se reinicia el turno            END IF         END IF      END IF     ENDPUBLIC SUB mnuConfiguracionSalir_Click()  ME.CloseENDPUBLIC SUB mnuConfiguracionNuevoJuego_Click()  DIM tam_botones AS Integer 'para seleccionar el tamaño adecuado del boton de acuerdo al nivel de juego escogido                             'Choose the board size     IF tam_tablero=8 THEN    tam_botones=40  ELSE    tam_botones=45  END IF      funciones.distrib(tam_tablero,tam_botones)ENDPUBLIC SUB grupobotones_KeyPress()    IF key.code=key.f4 THEN    habilitar=TRUE    timer2.Enabled=TRUE         label5.caption="PULSE F2 PARA REPARTIR DE NUEVO"         END IF    ENDPUBLIC SUB Timer1_Timer()   timer1.Enabled=FALSE ME.botones[boton_ultimo_paratimer].picture=ME.btnInicial.Picture ME.botones[boton_actual_paratimer].picture=ME.btnInicial.Picture  'ME.Label5.Caption="anterior: " & anterior_boton_jugado & "    ultimo: " & ultimo_boton_jugado  'message("hola") ME.habilitar=TRUE END'Habilita o deshabilita el menu sonido, esto permite posteriormente en el procedimiento sonar, escoger si se emiten o no'los sonidos'................................................................................................'Activate or desactivate the sound in menu Configuration.PUBLIC SUB mnuConfiguracionSonido_Click()  mnuConfiguracionSonido.Checked=NOT mnuConfiguracionSonido.CheckedEND'Para emitir los sonidos, si el menu Sonido no esta checkeado, se omite el sonidito'..................................................................................'Play sound only if Sound configuration menu is checkedPUBLIC SUB sonar (evento AS Integer)    IF ME.mnuConfiguracionSonido.Checked THEN     IF evento=1 THEN       ME.sonido.Play ()     END IF          IF evento=2 THEN       ME.aplauso.Play ()     END IF  END IF   ENDPUBLIC SUB Timer2_Timer()  'Este timer sirve para llevar la cuenta del tiempo de juego    '..........................................................  'This timer count the game time  funciones.tiempo=funciones.tiempo+1  ME.lblTiempo.Caption=funciones.tiempoENDPUBLIC SUB nivel_Click()  LAST.checked=NOT LAST.checked  IF LAST.tag="p" THEN      'message ("Has escogido el nivel Principiante")    ME.mnuConfigNivelExp.Checked=FALSE     ME.mnuConfigNivelMedio.Checked=FALSE           tam_tablero=4    funciones.distrib(tam_tablero,45)  END IF  IF LAST.tag="m" THEN    ME.mnuConfigNivelExp.Checked=FALSE     ME.mnuConfigNivelPrinci.Checked=FALSE           'message ("Has escogido el nivel Medio")        tam_tablero=6    funciones.distrib(tam_tablero,45)  END IF    IF LAST.tag="e" THEN    ME.mnuConfigNivelPrinci.Checked=FALSE     ME.mnuConfigNivelMedio.Checked=FALSE           'message ("Has escogido el nivel Experto, suerte jugadorazo!")     tam_tablero=8    funciones.distrib(tam_tablero,40)  END IF    ENDPUBLIC SUB mnuAyudaAcerca_Click()  frmAcerca.ShowModal   ENDPUBLIC SUB mnuAyudaInstr_Click()  frmInstrucciones.ShowModalENDPUBLIC SUB mnuConfigIdiomaEspanol_Click()  'Cambiar el idioma  '..................  'Set the language  ME.language="espanol"  ME.mnuConfigIdiomaEnglish.Checked=FALSE  ME.mnuConfigIdiomaEspanol.Checked=NOT ME.mnuConfigIdiomaEspanol.Checked  'File.Save("language.txt","espanol")  ME.set_enviroment_language  ENDPUBLIC SUB mnuConfigIdiomaEnglish_Click()  'Cambiar el idioma  '..................  'Set the language  ME.language="english"  ME.mnuConfigIdiomaEspanol.Checked=FALSE  ME.mnuConfigIdiomaEnglish.Checked=NOT ME.mnuConfigIdiomaEnglish.Checked  'File.Save("language.txt","espanol")  ME.set_enviroment_language END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -