コード例 #1
0
def main():
    global seleccion,nomPersonaje,personajeSelec
    ## creacion, lectura y escritura del texo puntaje
    lecturaP('puntaje.txt')
    escrituraP(Puntajes,'records')
    pygame.init()#sentencia obligatoria
    ventana = pygame.display.set_mode((anchoV,largoV))#recibe una tupla
    pygame.display.set_caption("Menu")
    fondo = pygame.image.load("imagenes/fondo.jpg").convert()
    fondo = pygame.transform.scale(fondo,(anchoV,largoV))
    marco = pygame.image.load("botones/marco2.png")
    marco = pygame.transform.scale(marco,(500,450))
    cursor1 = Cursor()
    boton1 = Boton(imagen1,imagen2,100,265)
    boton2 = Boton(imagen3,imagen4,100,365)
    boton3 = Boton(imagen5,imagen6,100,465)
    boton4 = Boton(imagen7,imagen8,100,565)
    boton5 = Boton(imagen9,imagen10,560,360)
    boton6 = Boton(imagen11,imagen12,560,460)

    fuente1= pygame.font.SysFont("Arial", 23, True, False)
    pygame.mixer.music.load("audio/intro.mp3")
    pygame.mixer.music.play()
    while True:
        ventana.blit(fondo,(0,0))
        ventana.blit(marco,(330,235))
        
        for evento in pygame.event.get():
            if evento.type == pygame.MOUSEBUTTONDOWN:
                if cursor1.colliderect(boton1.rect):
                    seleccion = 1
                elif cursor1.colliderect(boton2.rect):
                    seleccion = 2
                elif cursor1.colliderect(boton3.rect):
                    seleccion = 3
                elif cursor1.colliderect(boton4.rect):
                    seleccion = 4
                    pygame.quit()
                    sys.exit()
                elif cursor1.colliderect(boton5.rect):
                    nomPersonaje = "Mario"
                    personajeSelec = True
                elif cursor1.colliderect(boton6.rect):
                    nomPersonaje = "Seiya"
                    personajeSelec = True
                    
            if evento.type == pygame.QUIT:
                pygame.quit()#detenemos todos los modulos
                sys.exit()
                
        mensaje,posx,posy = opciones(seleccion,fuente1,ventana)
        texto =  fuente1.render(mensaje,1,blanco)
        personaje(seleccion,nomPersonaje,boton5,boton6,ventana,cursor1,fuente1)
        cursor1.update()
        boton1.update(ventana,cursor1)
        boton2.update(ventana,cursor1)
        boton3.update(ventana,cursor1)
        boton4.update(ventana,cursor1)
        ventana.blit(texto,(posx,posy))
        pygame.display.update()
コード例 #2
0
ファイル: Menu_Tutorial.py プロジェクト: CDonosoK/-_SUDOKU_-
def Menu_Tutorial():
    pygame.init()
    Ancho = 600
    Alto = 600
    FPS = pygame.time.Clock()
    Window = pygame.display.set_mode([Ancho, Alto])
    pygame.display.set_caption("-_Sudoku_-")

    cursor = Cursor()

    pygame.display.set_icon(IMG["Icono"])
    BotonSalir = Boton(IMG["Salir_0"], IMG["Salir_1"], 400, 540)

    Salir = False

    while not Salir:
        FPS.tick(60)

        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                Salir = True
            if evento.type == pygame.MOUSEBUTTONDOWN:
                if cursor.colliderect(BotonSalir.rect):
                    Salir = True

        pygame.display.update()
        cursor.Update()
        Window.blit(IMG["Fondo_Tutorial"], (0, 0))
        BotonSalir.Update(Window, cursor)
コード例 #3
0
ファイル: Sudoku_16.py プロジェクト: CDonosoK/-_SUDOKU_-
    def __init__(self, dificultad):
        pygame.init()

        pygame.mixer.music.load(MUS["Musica_Juego"])
        pygame.mixer.music.play(100)
        self.ventana = pygame.display.set_mode((Ancho_Sudoku, Alto_Sudoku))
        pygame.display.set_caption(Nombre)

        Ayuda_0 = IMG["Ayuda_0"]
        Ayuda_1 = IMG["Ayuda_1"]
        self.botonAyuda = Boton(pygame.transform.scale(Ayuda_0, (50, 50)),
                                pygame.transform.scale(Ayuda_1, (50, 50)), 110,
                                25)
        Exit_0 = IMG["Exit_0"]
        Exit_1 = IMG["Exit_1"]
        self.botonSalir = Boton(pygame.transform.scale(Exit_0, (50, 50)),
                                pygame.transform.scale(Exit_1, (50, 50)), 475,
                                25)
        Solucion_0 = IMG["Solucion_0"]
        Solucion_1 = IMG["Solucion_1"]
        self.botonSolucion = Boton(
            pygame.transform.scale(Solucion_0, (50, 50)),
            pygame.transform.scale(Solucion_1, (50, 50)), 50, 25)

        self.cursor = Cursor()

        self.comienzo = time.time()
        self.vacio = 1
        self.FPS = pygame.time.Clock()

        self.tiempoJugado = 0
        self.aux = 0
        self.texto = ""
        self.ayuda = False
        self.cantida_ayuda = 2
        self.casillaAyuda = (0, 0)
        self.salir = False

        self.jugando = True
        self.seleccion = None
        self.posMouse = None
        self.numero = False
        self.dificultad = dificultad

        self.Dieciseis = True
        self.Dieciseis_listo = 0

        #PLANO 16x16
        self.Solucion_16 = CrearSudoku(16)
        self.Plano16 = VaciadoAleatorio(self.Solucion_16, 16, self.dificultad)
        self.casillasProtegidas16 = []
        self.casillasProbables16 = []
        for fila16 in range(16):
            for columna16 in range(16):
                if self.Plano16[fila16][columna16] != 0:
                    self.casillasProtegidas16.append((columna16, fila16))
                else:
                    self.casillasProbables16.append((columna16, fila16))
コード例 #4
0
    def salaries(cls, id):
        with Cursor.Cursor() as cursor:
            cursor.execute(cls._SALARIES, id)
            informacion_salario = cursor.fetchall()

            log.info(f'Informacion salarial {informacion_salario}')
            return informacion_salario
コード例 #5
0
    def delete(cls, empleado):
        with Cursor.Cursor() as cursor:
            valores = (empleado.id, )

            cursor.execute(cls._DELETE, valores)
            log.info(f'Empleado Eliminado: {empleado}')
            return cursor.rowcount
コード例 #6
0
    def select(cls, id):
        with Cursor.Cursor() as cursor:
            cursor.execute(cls._SELECT, id)
            informacion_empleado = cursor.fetchall()

            log.info(f'Empleado seleccionado {informacion_empleado}')
            return informacion_empleado
コード例 #7
0
    def update(cls, empleado):
        with Cursor.Cursor() as cursor:
            valores = (empleado.nacimiento, empleado.nombre, empleado.apellido,
                       empleado.sexo, empleado.contrato, empleado.id)

            cursor.execute(cls._UPDATE, valores)
            log.info(f'Empleado actualizado: {empleado}')
            return cursor.rowcount
コード例 #8
0
    def insert(cls, empleado):
        with Cursor.Cursor() as cursor:
            valores = (empleado.id, empleado.nacimiento, empleado.nombre,
                       empleado.apellido, empleado.sexo, empleado.contrato)

            cursor.execute(cls._INSERT, valores)
            log.info(f'Empleado insertado: {empleado}')
            return cursor.rowcount
コード例 #9
0
ファイル: Main_Menu.py プロジェクト: CDonosoK/-_SUDOKU_-
def Main_Menu():
    pygame.init()
    Ancho = 600
    Alto = 600
    FPS = pygame.time.Clock()
    Window = pygame.display.set_mode([Ancho, Alto])
    pygame.display.set_caption("-_Sudoku_-")

    cursor = Cursor()
    pygame.mixer.music.load(MUS["Musica_Menu"])
    pygame.mixer.music.play(10)

    pygame.display.set_icon(IMG["Icono"])
    BotonStart = Boton(IMG["Start_0"], IMG["Start_1"], 380, 280)
    BotonTutorial = Boton(IMG["Tutorial_0"], IMG["Tutorial_1"], 380, 330)
    BotonSalir = Boton(IMG["Salir_0"], IMG["Salir_1"], 380, 380)

    Salir = False

    while not Salir:
        FPS.tick(60)

        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                Salir = True
            if evento.type == pygame.MOUSEBUTTONDOWN:
                if cursor.colliderect(BotonSalir.rect):
                    Salir = True

                if cursor.colliderect(BotonStart.rect):
                    Menu_Opciones()

                if cursor.colliderect(BotonTutorial.rect):
                    Menu_Tutorial()

        pygame.display.update()
        cursor.Update()
        Window.blit(IMG["Fondo_Main"], (0, 0))
        BotonStart.Update(Window, cursor)
        BotonTutorial.Update(Window, cursor)
        BotonSalir.Update(Window, cursor)
    pygame.quit()
コード例 #10
0
ファイル: Sudoku_4.py プロジェクト: CDonosoK/-_SUDOKU_-
class Sudoku_4():
    def __init__(self, dificultad):
        pygame.init()

        pygame.mixer.music.load(MUS["Musica_Juego"])
        pygame.mixer.music.play(100)
        self.ventana = pygame.display.set_mode((Ancho_Sudoku, Alto_Sudoku))
        pygame.display.set_caption(Nombre)

        Ayuda_0 = IMG["Ayuda_0"]
        Ayuda_1 = IMG["Ayuda_1"]
        self.botonAyuda = Boton(pygame.transform.scale(Ayuda_0, (50, 50)), pygame.transform.scale(Ayuda_1, (50, 50)), 110, 40)
        Exit_0 = IMG["Exit_0"]
        Exit_1 = IMG["Exit_1"]
        self.botonSalir = Boton(pygame.transform.scale(Exit_0, (50, 50)), pygame.transform.scale(Exit_1, (50, 50)), 475, 40)
        Solucion_0 = IMG["Solucion_0"]
        Solucion_1 = IMG["Solucion_1"]
        self.botonSolucion = Boton(pygame.transform.scale(Solucion_0, (50, 50)), pygame.transform.scale(Solucion_1, (50, 50)), 50, 40)
        self.cursor = Cursor()

        self.comienzo = time.time()
        self.vacio = 1
        self.FPS = pygame.time.Clock()

        self.tiempoJugado = 0
        self.aux = 0
        self.texto = ""
        self.ayuda = False
        self.cantida_ayuda = 2
        self.casillaAyuda = (0,0)
        self.salir = False

        self.jugando = True
        self.seleccion = None
        self.posMouse = None
        self.numero = False
        self.dificultad = dificultad

        self.Cuatro = True
        self.Cuatro_listo = 0

        #PLANO 4x4
        self.Solucion_4 = CrearSudoku(4)
        self.Plano4 = VaciadoAleatorio(self.Solucion_4, 4, self.dificultad)
        self.casillasProtegidas4 = []
        self.casillasProbables4 = []
        for fila4 in range(4):
            for columna4 in range(4):
                if self.Plano4[fila4][columna4] != 0:
                    self.casillasProtegidas4.append((columna4, fila4))
                else:
                    self.casillasProbables4.append((columna4, fila4))

    def Jugar(self):
        self.FPS.tick(60)
        while self.jugando:
            self.tiempoJugado = round(time.time() - self.comienzo)

            self.Eventos()
            self.Actualizar()

            if self.Cuatro:
                if self.CasillasPosibles(self.Plano4, 0):
                    if self.Plano4 == self.Solucion_4:
                        self.Cuatro_listo = 1
                    else:
                        self.Cuatro_listo = 2
                    pygame.mixer.music.stop()
                    self.jugando = False
            self.Dibujar()

        if self.Cuatro_listo == 1:
            pygame.mixer.music.load(MUS["Musica_Ganar"])
            pygame.mixer.music.play()
            time.sleep(7)
        if self.Cuatro_listo == 2:
            pygame.mixer.music.load(MUS["Musica_Perder"])
            pygame.mixer.music.play()
            time.sleep(5)

    def Eventos(self):
        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                self.jugando = False
                pygame.mixer.music.stop()

            if evento.type == pygame.MOUSEBUTTONDOWN:
                seleccionada = self.mousePlano()
                if (self.cursor.colliderect(self.botonSolucion.rect)):
                    self.Plano4 = self.Solucion_4

                if (self.cursor.colliderect(self.botonSalir.rect)):
                    pygame.mixer.music.stop()
                    self.salir = True
                    self.jugando = False
                    pygame.mixer.music.stop()

                if (self.cursor.colliderect(self.botonAyuda.rect)) and self.cantida_ayuda!= 1:
                    self.casillaAyuda = random.randint(0, len(self.casillasProbables4)-1)
                    self.cantida_ayuda = len(self.casillasProbables4)
                    self.casillaAyuda = self.casillasProbables4[self.casillaAyuda]
                    self.ayuda = True

                if seleccionada:
                    self.seleccion = [1,2]
                    self.seleccion[0] = seleccionada[0] - 3
                    self.seleccion[1] = seleccionada[1] - 1
                    self.seleccion = (self.seleccion[0], self.seleccion[1])
                    if self.seleccion in self.casillasProtegidas4:
                        self.seleccion = None
                else:
                    self.seleccion = None

            if evento.type == pygame.KEYDOWN:
                self.tecla = pygame.key.name(evento.key)
                if self.tecla == "escape":
                    self.jugando = False
                    pygame.mixer.music.stop()

                if self.seleccion:
                    if self.tecla == "return" or self.tecla == "space" or self.tecla == "enter":
                        if self.aux not in ['1','2','3','4']:
                            self.aux = 0
                        self.Plano4[self.seleccion[1]][self.seleccion[0]] = int(self.aux)
                        self.numero = False
                        self.aux = ""

                    if self.tecla in ['1','2','3','4'] or self.tecla in ['[1]','[2]','[3]','[4]']:
                        if self.tecla in ['[1]','[2]','[3]','[4]']:
                            self.tecla = self.tecla[1:-1]
                            self.tecla = int(self.tecla)
                        self.numero = True
                        self.aux = self.tecla
                    else:
                        self.numero = False


    def mousePlano(self):
        if self.posMouse[0] < (posInicial_4[0]+150) or self.posMouse[1] < (posInicial_4[1] + 50):
            return False

        if self.posMouse[0] > (posInicial_4[0] + tamañoPlano_4 + 150) or self.posMouse[1] > (posInicial_4[1] + tamañoPlano_4 + 50):
            return False

        return ((self.posMouse[0]-posInicial_4[0])//tamañoCelda_4, (self.posMouse[1] - posInicial_4[1])// tamañoCelda_4)

    def Actualizar(self):
        self.posMouse = pygame.mouse.get_pos()
        self.cursor.Update()

    def Dibujar(self):
        self.ventana.blit(IMG["Fondo_Sudoku"], (0,0))
        if self.Cuatro_listo == 1:
            self.dibujarGanaste(self.ventana)
        if self.Cuatro_listo == 2:
            self.dibujarPerdiste(self.ventana
                                 )
        self.botonAyuda.Update(self.ventana, self.cursor)
        self.botonSolucion.Update(self.ventana, self.cursor)
        self.botonSalir.Update(self.ventana, self.cursor)
        self.segundos = self.tiempoJugado%60
        self.minutos = self.tiempoJugado//60
        self.horas = self.minutos//60
        tiempoTexto = " "+str(self.horas)+" : "+str(self.minutos)+" : "+str(self.segundos)
        self.tiempoTexto = pygame.font.Font('Mario_Bros.TTF', 18).render("TIEMPO JUGADO"+tiempoTexto,1, Negro )
        self.ventana.blit(self.tiempoTexto, (170, 60))


        if self.Cuatro:
            if self.ayuda:
                self.ayuda = False
                self.casillasProtegidas4.append(self.casillaAyuda)
                self.casillasProbables4.remove((self.casillaAyuda[0], self.casillaAyuda[1]))
                self.Plano4[self.casillaAyuda[1]][self.casillaAyuda[0]] = int(self.Solucion_4[self.casillaAyuda[1]][self.casillaAyuda[0]])

            if self.seleccion:
                self.dibujarSeleccion(self.ventana, self.seleccion, tamañoCelda_9)
            if self.numero and self.seleccion:
                self.texto = pygame.font.Font('Mario_Bros.TTF', 40).render(str(self.tecla), 1, Negro)
                self.ventana.blit(self.texto, (self.seleccion[0]* tamañoCelda_9 + posInicial_4[0] + 165, self.seleccion[1]*tamañoCelda_9 + posInicial_4[1] + 55))

            self.Dibujar4(self.ventana)
            for fila in range(4):
                for columna in range(4):
                    if self.Plano4[fila][columna] == 0:
                        self.texto = pygame.font.Font('Mario_Bros.TTF', 40).render("", 1, Negro)
                    else:
                        self.texto = pygame.font.Font('Mario_Bros.TTF', 40).render(str(self.Plano4[fila][columna]), 1, Negro)
                    self.ventana.blit(self.texto, (columna * tamañoCelda_9 + posInicial_4[0] + 165, fila * tamañoCelda_9 + posInicial_4[1] + 55))
        pygame.display.update()

    def dibujarSeleccion(self, pantalla, posicion, tamaño):
        pygame.draw.rect(pantalla, Celeste, (((posicion[0])* tamaño) + posInicial_4[0] + 150 , ((posicion[1])* tamaño) + posInicial_4[1] + 50, tamaño, tamaño))

    def dibujarGanaste(self, pantalla):
        self.texto = pygame.font.Font('Mario_Bros.TTF', 40).render("GANASTE", 1, Verde)
        pantalla.blit(self.texto, (200, 10))

    def dibujarPerdiste(self, pantalla):
        self.texto = pygame.font.Font('Mario_Bros.TTF', 40).render("PERDISTE", 1, Rojo)
        pantalla.blit(self.texto, (200, 10))

    def Dibujar4(self, pantalla):
        pygame.draw.rect(pantalla, Negro, (posInicial_4[0]+150, posInicial_4[1]+50, Ancho_Sudoku-400, Alto_Sudoku-400), 3)
        for x in range(4):
            if x % 2 != 0:
                pygame.draw.line(pantalla, Negro, (posInicial_4[0] + (x * tamañoCelda_4 ) + 150 ,posInicial_4[1] + 50), (posInicial_4[0] + (x * tamañoCelda_4 ) + 150 , posInicial_4[1]+250))
                pygame.draw.line(pantalla, Negro, (posInicial_4[0] + 150, posInicial_4[1] + (x * tamañoCelda_4 ) + 50), (posInicial_4[0] + 350, posInicial_4[1] + (x * tamañoCelda_4 ) + 50))
            else:
                pygame.draw.line(pantalla, Negro, (posInicial_4[0] + (x * tamañoCelda_4 ) + 150, posInicial_4[1] + 50), (posInicial_4[0] + (x * tamañoCelda_4 ) + 150, posInicial_4[1] + 250), 3)
                pygame.draw.line(pantalla, Negro, (posInicial_4[0] + 150, posInicial_4[1] + (x * tamañoCelda_4 ) + 50), (posInicial_4[0] + 350, posInicial_4[1] + (x * tamañoCelda_4 ) + 50), 3)

    def CasillasPosibles(self, plano, contador):
        contador = contador
        for i in plano:
            for j in i:
                if j == 0 or j == '0':
                    contador += 1
        if contador == 0:
            return True
        else:
            return False
コード例 #11
0
from Clases import Cursor, Boton
from Survival import bucle_juego

pygame.init()  #sentencia obligatoria
ventana = pygame.display.set_mode((800, 600))  #recibe una tupla
pygame.display.set_caption("Menu")
imagen1 = pygame.image.load("imagenes/boton1.jpg")
imagen2 = pygame.image.load("imagenes/boton1.1.jpg")
imagen3 = pygame.image.load("imagenes/boton2.jpg")
imagen4 = pygame.image.load("imagenes/boton2.1.jpg")
imagen5 = pygame.image.load("imagenes/boton3.jpg")
imagen6 = pygame.image.load("imagenes/boton3.1.jpg")

fondo = pygame.image.load("imagenes/fondo.jpg")

cursor1 = Cursor()
boton1 = Boton(imagen1, imagen2, 285, 250)
boton2 = Boton(imagen3, imagen4, 285, 350)
boton3 = Boton(imagen5, imagen6, 285, 450)
pygame.mixer.music.load("audio/intro.mp3")
pygame.mixer.music.play()
#mostrar esa ventana
while True:
    fondo = pygame.transform.scale(fondo, (800, 600))
    ventana.blit(fondo, (0, 0))

    for evento in pygame.event.get():
        if evento.type == pygame.MOUSEBUTTONDOWN:
            if cursor1.colliderect(boton1.rect):
                print("boton1")
                bucle_juego()
コード例 #12
0
def Menu_Opciones():
    pygame.init()

    Ancho = 600
    Alto = 600
    FPS = pygame.time.Clock()
    Window = pygame.display.set_mode([Ancho, Alto])
    pygame.display.set_caption("-_Sudoku_-")

    cursor = Cursor()

    pygame.display.set_icon(IMG["Icono"])
    BotonSalir = Boton(IMG["Salir_0"], IMG["Salir_1"], 205, 450)

    BotonS4 = Boton(IMG["4x4_0"], IMG["4x4_1"], 30, 200)
    BotonS9 = Boton(IMG["9x9_0"], IMG["9x9_1"], 30, 270)
    BotonS16 = Boton(IMG["16x16_0"], IMG["16x16_1"], 30, 340)

    BotonFacil = Boton(IMG["Facil_0"], IMG["Facil_1"], 440, 200)
    BotonMedio = Boton(IMG["Medio_0"], IMG["Medio_1"], 440, 270)
    BotonDificil = Boton(IMG["Dificil_0"], IMG["Dificil_1"], 440, 340)

    Salir = False
    Dificultad = None
    Tipo = None

    while not Salir:
        FPS.tick(60)

        for evento in pygame.event.get():
            if evento.type == pygame.QUIT:
                Salir = True
            if evento.type == pygame.MOUSEBUTTONDOWN:
                if cursor.colliderect(BotonSalir.rect):
                    Salir = True

                if cursor.colliderect(BotonS4.rect):
                    Tipo = 4
                if cursor.colliderect(BotonS9.rect):
                    Tipo = 9
                if cursor.colliderect(BotonS16.rect):
                    Tipo = 16

                if cursor.colliderect(BotonFacil.rect):
                    Dificultad = 1
                if cursor.colliderect(BotonMedio.rect):
                    Dificultad = 2
                if cursor.colliderect(BotonDificil.rect):
                    Dificultad = 3

        if Tipo != None and Dificultad != None:
            if Tipo == 4:
                Sudoku = Sudoku_4(Dificultad)
            if Tipo == 9:
                Sudoku = Sudoku_9(Dificultad)
            if Tipo == 16:
                Sudoku = Sudoku_16(Dificultad)

            Sudoku.Jugar()
            pygame.mixer.music.load(MUS["Musica_Menu"])
            pygame.mixer.music.play(10)
            Tipo = None
            Dificultad = None

        pygame.display.update()
        cursor.Update()
        Window.blit(IMG["Fondo_Menu"], (0, 0))
        BotonSalir.Update(Window, cursor)

        BotonS4.Update(Window, cursor)
        BotonS9.Update(Window, cursor)
        BotonS16.Update(Window, cursor)

        BotonFacil.Update(Window, cursor)
        BotonMedio.Update(Window, cursor)
        BotonDificil.Update(Window, cursor)