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

📄 funciones.module

📁 Gambas is a graphical development environment based on a Basic interpreter, like Visual Basic. It us
💻 MODULE
字号:
' Gambas module file'Arreglos para guardar info de las imagenes a cargar y el estado de los botones'................................................................................'Arrays for save images information to load.PRIVATE botones_numero_foticos[64] AS Integer 'Almacena el numero de foto (indice) que llevara cada botoncito al descubrirse                                              'Almacenate the image number (index).PRIVATE boton_lleno[64] AS Boolean 'para especificar si un boton ya recibio asignacion de fotico                                   'Specify if a button have a image asigned       'Variables de juegoPUBLIC jugadas AS Integer 'contador del numero de jugadas durante una partida (counter for number of movements)PUBLIC tiempo AS Integer 'contador del numero de segundos durante una partida (counter for game time)PUBLIC aciertos AS Integer 'Contar el numero de aciertos del jugador, es decir, cada vez que el jugador logra en una misma                           'jugada encontrar dos botones con el mismo dibujito                           '..............................................................................................                           'Count the acerts for player.PUBLIC num_movimiento_actual AS Integer 'Siempre tendra valor de 0, o 1. se usa para saber si el jugador ya destapo un boton el turno actual                                         'es decir, una jugada consta de dos movimientos                                         '..................................................................................                                         'Controle the set of button moved in a movementPUBLIC SUB distrib(tam_tablero AS Integer, tam_botones AS Integer)  DIM i AS Integer  DIM j AS Integer  DIM izq AS Integer  DIM arr AS Integer  DIM pos AS Integer    izq=(principal.Width-tam_botones*tam_tablero)/2  arr=(principal.Height-tam_botones*tam_tablero)/2    pos=0    FOR I=0 TO tam_tablero-1    FOR J=0 TO tam_tablero-1      principal.botones[pos].visible=TRUE      principal.botones[pos].width=tam_botones      principal.botones[pos].height=tam_botones      principal.botones[pos].x=izq      principal.botones[pos].y=arr      principal.botones[pos].picture=principal.btnInicial.Picture 'cada vez que se distribuye el tablero, se tapas los botone                                                                  'con el dibujito del signo de interrogacion                                                                   '........................................................                                                                  'Restore the buttons to initial state, when the game is                                                                  'restarted      'principal.botones[pos].enabled=TRUE      izq=izq+tam_botones      pos=pos+1            NEXT    arr=arr+tam_botones    izq=(principal.Width-tam_botones*tam_tablero)/2      NEXT    'Se ocultan los botones que no sean necesarios de acuerdo al nivel  'de juego, esto pasa cuando se ha jugado en un nivel superior y  'luego se vuelve hacia un nivel inferior  '..................................................................  'The not necesary button are oculted  FOR I=tam_tablero*tam_tablero TO 63    principal.botones[pos].visible=FALSE    pos=pos+1  NEXT    'se asigna false al array boton_lleno para iniciar una nueva asignacion de foticos  '..................................................................................  'The state for each button is restored, it is for permit movement with each button  FOR I=0 TO 63    boton_lleno[I]=FALSE  NEXT    'Se cargan las imagenes en cada botoncito  '.........................................  'Load image for each button  repartir(tam_tablero*tam_tablero)END'Este procedimiento busca en el directorio imagenes para capturar los'nombres de los dibujitos que se van a mostrar en los botones, esta'funcionalidad permite que el usuario incluya luego sus propias imagenes'PUBLIC SUB cargar_imagenes(Directory AS String)  'DIM File AS String  'DIM indice AS Integer    'indice=0  'FOR EACH File IN Dir(Directory, "an*.gif")    'imagenes[indice]=File        'indice=indice+1      'NEXT  'ENDPUBLIC SUB repartir(tam_tablero AS Integer)    DIM i AS Integer    DIM j AS Integer    DIM aleatorio AS Integer    DIM aleatorio1 AS Integer    DIM listo AS Boolean 'Bandera para informar cuando se encuentre un boton libre para asignacion                         'Variable for controlate the flow in nex loop        'Ciclar la mitad de la dimension para ubicar las imagenes en cada boton, se cicla la mitad ya que cada imagen    'escogida en un ciclo se asigna a una pareja de botoncitos, la imagen escogida se representa como un numero    'entero, que es utilizado luego como indice del array botones_foticos[] para copiar la propiedad picture, este    'numero se guarda en el arreglo botones_numero_foticos[64].    '..............................................................................................................    'This For loop permit locate the images in each button     FOR i=0 TO Int(tam_tablero-1)/2       aleatorio=Int(Rnd()*40) 'se obtiene un numero entre (0, 39) que es el rango de indices del array botones_foticos                               'Obtain a random number in 0-39 range (there is 40 images for use)       'IF aleatorio = 40 THEN  message ("salio un numero malo")       'en cada ciclo se ubica dos veces la misma fotico en dos cuadros aleatorios       '..........................................................................       'For each loop a image is locate at two times       FOR j=0 TO 1         listo=FALSE         WHILE listo=FALSE 'se anida este ciclo para forzar la busqueda de dos cuadritos que no hayan sido asignados                           'This loop is nested for force the search           aleatorio1=Int(Rnd()*tam_tablero) 'se busca un indice en el rango (0, tam_tablero)                                             'An index in 0,tam_table range is searched           IF (boton_lleno[aleatorio1])=FALSE THEN 'se verifica que el boton no tenga fotico asignada                                                    'Verify the button for stablish it is free                         botones_numero_foticos[aleatorio1]=aleatorio             boton_lleno[aleatorio1]=TRUE             listo=TRUE                          'ACTIVAR LA LINEA SIGUIENTE PARA DEPURACION, ENTONCES SE PODRA VER LA IMAGEN OCULTA DE LOS BOTONES             'principal.botones[aleatorio1].picture=principal.botones_foticos[aleatorio].picture           END IF                    WEND                NEXT            NEXT           'El timer del contador de segundos ha de estar en ceros     '......................................................     'Restore the time game timer      principal.Timer2.Enabled=FALSE     'Se inicializan las variables de juego     '....................................     'Initialize game variables      jugadas=0      tiempo=0      aciertos=0      num_movimiento_actual=0            'Se inicializan los labels de conteo del juego      '.............................................      'Initialize labels      principal.lblJugadas.Caption=0      principal.lblTiempo.Caption=0      'Se actualiza el mensaje en la barra de estado      '..............................................      'Change message in status bar      principal.Label5.caption="PULSE F4 PARA COMENZAR LA MISION"                  principal.habilitar=FALSE 'El jugador no puede descubrir las fichas hasta que pulse F4                                 '.........................................................                                'Enable game only when player press F4     END'Se hace necesario este metodo para notificar al formulario principal sobre cual imagen debe colocar en un botoncito'al ser descubierto, esto debido a que el arreglo botones_numero_foticos[] es pridado en este moduloPUBLIC FUNCTION devolver_indice_defotico (tag AS Integer) AS Integer   RETURN botones_numero_foticos[tag]END'Devuelve un valor booleano indicando si los dos movimientos de una jugada son validosPUBLIC FUNCTION comparar_botones_jugados (btjugado1 AS Integer, btjugado2 AS Integer) AS Boolean  RETURN botones_numero_foticos[btjugado1] = botones_numero_foticos[btjugado2]END

⌨️ 快捷键说明

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