Beispiel #1
0
def main():
    L = []
    while True:
        menu()
        s = input("请选择:")
        if s == '1':
            L += input_student()
        elif s == '2':
            output_student(L)
        elif s == '3':
            change_student(L)
        elif s == '4':
            delete_student(L)
        elif s == '5':
            scoreHighToLow(L)
        elif s == '6':
            scoreLowToHigh(L)
        elif s == '7':
            ageOldToYoung(L)
        elif s == '8':
            ageYoungToOld(L)
        elif s == '9':
            student_info_save(L)
        elif s == '10':
            student_info_read()

        else:
            break
Beispiel #2
0
def main():
    while True:
        menu()
        cmd = input("请输入命令:")
        if cmd not in ['1', '2', '3', '4', '5', '6', '7', '8'] or not cmd:
            print("输入命令错误,请重新输入")
        else:
            if cmd == "1":
                scode1(cmd)
            elif cmd == "2":
                scode2(cmd)
            elif cmd == "3":
                scode3(cmd)
            elif cmd == "4":
                scode4(cmd)
            elif cmd == "5":
                scode5(cmd)
            elif cmd == "6":
                scode6(cmd)
            elif cmd == "7":
                scode7(cmd)
            elif cmd == "8":
                data = input("是否退出系统,Y/N")
                if data == 'Y':
                    print("退出系统")
                    return
                elif data == 'N':
                    continue
Beispiel #3
0
def main():

    try:
        with open("reminders.json") as f:
            reminders = json.load(f)
    except FileNotFoundError:
        reminders = []

    while True:
        menu()
        choice = get_int("Choose from menu: ")
        if choice == 1:
            reminder = input("Type reminder: ")
            reminders.append(reminder)
            with open("reminders.json", "w") as f:
                json.dump(reminders, f)

        elif choice == 2:
            reminder_index = get_int("Give index of the reminder: ") - 1
            reminders.pop(reminder_index)
            with open("reminders.json", "w") as f:
                json.dump(reminders, f)

        elif choice == 3:
            for i in range(len(reminders)):
                print(f"{i+1}. {reminders[i]}")

        elif choice == 4:
            print("Bye!")
            break
Beispiel #4
0
def move_brush():
    global gui_on
    global select_column
    global select_row
    global c

    press = pygame.key.get_pressed()

    if press[K_w] == 1:
        Brush.move(0,-3)
    if press[K_a] == 1:
        Brush.move(-3,0)
    if press[K_s] == 1:
        Brush.move(0,3)
    if press[K_d] == 1:
        Brush.move(3,0)
    if press[K_MINUS] or press[K_KP_MINUS] == 1:
        Brush.size(-3,-3)
    if press[K_EQUALS] or press[K_PLUS] or press[K_KP_PLUS] == 1:
        Brush.size(3,3)
    if press[K_c] == 1:
        pygame.mouse.set_visible(1)
        select_column = 70
        select_row = 75
        menu()
        Brush.change_colors()
        pygame.mouse.set_visible(0)
Beispiel #5
0
def main():
    L = []
    f = Student()
    while True:
        menu()
        s = input("请选择:")
        if s == '1':
            L = f.input_student()
            f.set_L(L)
        elif s == '2':
            f.output_student()
        elif s == '3':
            f.change_student()
        elif s == '4':
            f.delete_student()
        elif s == '5':
            f.scoreHighToLow()
        elif s == '6':
            f.scoreLowToHigh()
        elif s == '7':
            f.ageOldToYoung()
        elif s == '8':
            f.ageYoungToOld()
        elif s == '9':
            f.student_info_save()
        elif s == '10':
            f.student_info_read()

        else:
            break
Beispiel #6
0
def move_brush():
    global gui_on
    global select_column
    global select_row
    global c

    press = pygame.key.get_pressed()

    if press[K_w] == 1:
        Brush.move(0, -3)
    if press[K_a] == 1:
        Brush.move(-3, 0)
    if press[K_s] == 1:
        Brush.move(0, 3)
    if press[K_d] == 1:
        Brush.move(3, 0)
    if press[K_MINUS] or press[K_KP_MINUS] == 1:
        Brush.size(-3, -3)
    if press[K_EQUALS] or press[K_PLUS] or press[K_KP_PLUS] == 1:
        Brush.size(3, 3)
    if press[K_c] == 1:
        pygame.mouse.set_visible(1)
        select_column = 70
        select_row = 75
        menu()
        Brush.change_colors()
        pygame.mouse.set_visible(0)
Beispiel #7
0
def get_client_id(message, tekUser):
    Found = 0
    tekUser.Cards = []
    url = 'http://185.80.232.179:8090/FB570E97-40C5-4690-9037-94E20BC0BC88/dcard?dcardcode=' + tekUser.phone_nuber
    #    print(url)
    res = requests.get(url)
    filename = pth + str(tekUser.chat_id) + '.xml'
    f = open(filename, 'w')
    f.write(res.text)
    f.close()

    tree = ET.parse(filename)
    root = tree.getroot()

    ErrorCode = root[0][0].text

    print('ErrorCode =  ', ErrorCode)

    if ErrorCode != '0':
        print('Неизвестный номер телефона')
        tekUser.Last_message = bot.send_message(message.from_user.id, 'В базі даних не знайдено жодного запису, Такого номера телефону немає.')
    else:
        for child in root:
            if child.tag == 'Results':
                for child1 in child:
                    if child1.tag == 'ResultQuery':
                        Found = 1
                        s = []
                        for child2 in child1:
                            if child2.tag == 'DCARDID':
                                s.append(child2.text)
                            if child2.tag == 'CLNTID':
                                s.append(child2.text)
                            if child2.tag == 'DCARDCODE':
                                s.append(child2.text)
                            if child2.tag == 'LOCKED':
                                s.append(child2.text)
                        if s[3] == '0':
                            print(s[2],len(s[2]))
                            if len(s[2]) == 13:
                                tekUser.Cards.append(s)
    #    s = tekUser.Cards[0]
    #    print(s[2])
    if Found == 1:
        if len(tekUser.Cards) > 1:
            s = tekUser.Cards[0]
            tekUser.client_id = s[1]
            ChoiseCard(message, tekUser)
        else:
            s = tekUser.Cards[0]
            tekUser.karta_id = s[0]
            tekUser.client_id = s[1]
            tekUser.karta = s[2]
            get_client(message, tekUser)
            AfterAvtor(message, tekUser)
    else:
        print('Неизвестный номер телефона')
        tekUser.Last_message = bot.send_message(message.from_user.id, 'В базі даних не знайдено жодного запису, Такого номера телефону немає.')
        menu(message, tekUser)
Beispiel #8
0
def wronans(message, tekUser):
    if tekUser == -1:
        Kepper.NewChat(message.chat.id)
        tekUser = Kepper.find(message)
    tekUser.Last_message = bot.send_message(message.from_user.id, 'Не той код. Авторизація не пройдена')
    tekUser.enter_sms = 0
    tekUser.enter_mode = 0
    menu(message, tekUser)
Beispiel #9
0
def main(scr):
    neophyte.default_color()
    m = menu("menu1", ["Yes", "No"])
    y = menu("menu2" ,["Either", "Or"])
    m.display(scr)
    y.display(scr)
    scr.curse.getkey() 
    m.hide(scr) 
    scr.curse.getkey()
Beispiel #10
0
def main():

    # getAllStats()
    menu()

    players = gatherPlayers()

    name = input('Enter the full name of the player you want stats on:')

    careerStats(name, players)
Beispiel #11
0
def go_to_game():

    ans_human = menu('Введите кол-во игроков (людей)',
                     ['1. 1-игрок', '2. 2-игрока', '0. Без людей'],
                     ['1', '2', '0'])
    ans_computer = menu('Введите кол-во игроков (компьютеров)',
                        ['1. 1-игрок', '2. 2-игрока', '0. Без компьютеров'],
                        ['1', '2', '0'])
    if int(ans_human) + int(ans_computer) == 0:
        print('Нужен хотя-бы один игрок, хоть сам с собой')
        return
    game(int(ans_human), int(ans_computer))
Beispiel #12
0
def main():
    modes = ["user", "automatic"]
    mode = menu(modes, "Method of gathering data:",
                "Choose a data gathering method: ")
    labels = ["attentive", "inattentive"]
    label_idx = menu(labels, "Label:",
                     "Enter the label you would like to add data for: ")
    label = labels[label_idx]
    print(f"Capturing data for label: {label}")
    if mode == 0:
        capture(label)
    else:
        auto_capture(label)
def menu():

    menu = {}
    menu['1'] = "Easy level with 7 lives"
    menu['2'] = "Medium level with 5 lives"
    menu['3'] = "Hard level with 3 lives"
    menu['4'] = "Exit"
    while True:
        options = menu.keys()
        options.sort()
        for entry in options:
            print(entry, menu[entry])

        selection = raw_input("Please Select:")
        if selection == '1':
            print("Selected: easy level with 7 lives!")
        elif selection == '2':
            print("Selected: medium level with 5 lives!")
        elif selection == '3':
            print("Selected: hard level with 3 lives!")
        elif selection == '4':
            break
        else:
            print("Unknown Option Selected!")
        return menu()
def main():
    logging.basicConfig(
        datefmt="%Y-%m-%dT%H:%M:%S",
        format='%(asctime)s+%(msecs)03d %(name)s %(levelname)s: %(message)s',
        level=logging.INFO)
    # Assure py3
    assure_py3()

    # Get the cli params
    cli_params = menu()
    if cli_params.manual:
        print(open('README.md').read())

    # Interface
    interface = {
        "inventory": cli_params.inventory,
        "output": cli_params.output,
        #"plot": cli_params.inventory.replace(".", "_plot."),
    }

    # declare meta list to log the program progress
    logging.info("cli_params " + str(cli_params))
    logging.info("interface " + str(interface))
    #if cli_params.net:
    #    tnet.main(inventory_jl=interface["inventory"], network_jl=interface["network"], pvs_jl=interface["pvs"])
    yaml2xml.main(in_yl=interface["inventory"], out_xl=interface["output"])
Beispiel #15
0
def main():
    # quantidade de atendentes da simulação
    atendentes = 2

    # salvar as opções do usuário
    tec_distr = {}
    ts_distr = {}

    # menu que apresenta as opções
    tec_nome, tec_valor, ts_nome, ts_valor, limite_fila = menu()

    # distribuição do tec e ts
    tec_distr[tec_nome] = tec_valor
    ts_distr[ts_nome] = ts_valor

    resultado_simulacao = realiza_simulacao(atendentes, tec_distr, ts_distr,
                                            limite_fila)
    resultado_simulacao[["Cliente", "Atendente"
                         ]] = resultado_simulacao[["Cliente",
                                                   "Atendente"]].astype(int)
    print(resultado_simulacao.to_string(index=False))

    # relatório das estatísticas
    print("\nNúmero Médio de Entidades nas Filas:",
          entidades_fila(resultado_simulacao))
    print("Tempo Médio de uma Entidade na Fila:",
          tempo_fila(resultado_simulacao))
    print("Tempo Médio no Sistema:", tempo_sistema(resultado_simulacao))

    medias = ocupacao_servidores(resultado_simulacao, atendentes)
    for atendente, media in enumerate(medias):
        print(f"Taxa Média de Ocupação do Servidor {atendente+1}:", media)
 def setUp(self):
     db.delete('MenuItems', where='1=1')
     self.input_mock = MagicMock()
     self.winput = patch('web.input')
     self.config_mock = MagicMock()
     self.config = patch('web.config', new=self.config_mock)
     self.config_mock._session.roleid = 1
     self.menued = menu()
Beispiel #17
0
def main():
    difficulty = menu()
    board = create_board(difficulty)
    print_board(board)
    result = 1
    while result != 0:
        win = 0
        board, message = user_insert(board)
        print_board(board, message)
        result = check_win(board, win)
Beispiel #18
0
def main(sc):
  sc.nodelay(1)
  curses.curs_set(0)
  while True:
      men1 = menu(3,3, ["Fitxategia", "Belle la France", "Aux Chiottes"])
      sc.refresh()
      men1.refresh()
      if sc.getch() == ord('q'):
         break
      time.sleep(1)
def main():

    #création des objets
    p = Partie()
    pl = Plateau()
    m = menu()

    #définition du choix à 0
    choix = 0

    #Tant que le choix n'est pas de lancer une partie 
    while choix != 1:
        m.affichage_main_menu()             #On affiche le menu
        choix = m.user_choix()              #On demande à l'utilisateur son choix
        
        if choix == 2:                      #Si son choix est de changer la taille
            pl.dimenssion = m.taille()          #On lui demande la taille qu'il veut
        elif choix == 3:                    #Si son choix est de changer le nombre de joueurs
           p.nbr_joueurs = m.nbr_joueur()          #On lui demande le nombre de joueurs
        elif choix == 4:                    #Si il veut connaitre les règles 
            webbrowser.open("http://www.ffothello.org/othello/regles-du-jeu/")  #On le redirige vers la page officiel avec les règles
        
        print("")   #saut de ligne

    #Une fois qu'il à lancer une partie on initialise la partie
    p.tab = pl.initialisation(nbr_joueurs=p.nbr_joueurs)

    #tant que la fin de partie n'est vérifié
    while pl.test(p.tab) == 0:
        p.joueurs()                                         #On définie qui joue 
        if pl.joueur_eliminer(p.tour, p.nbr_joueurs) == 0 : #Si le joueur n'est pas éliminé
            pl.affiche(p.tab, pl.dimenssion)                    #On affiche le plateau de jeu
            print("C'est à", p.joueurs_du_tour[0], "de jouer !")            #On affiche le nom du joueur qui doit jouer
            a = p.coup()                                                    #On lui demande ou il veux jouer 
            if a[0] != "":                                                  #Si l'utilisateur rentre autre chose que entrer(qui sert a sauté le tour)
                if p.validite_case(a, p.tab) == 0:                      #Si la case est vide
                    possibilite, valid_dir_lg, valid_dir_cl = p.validite_pos(a, p.tab)          #On récupère les variables de la methode validite_pos           
                    if possibilite >= 1:                                                        #Si on a au moins une possibilité de retourner un ou plusieurs pions
                        p.ajout_pion(a, p.tab)                                                  #On ajoute son pion
                        p.inversement(p.tab, a, valid_dir_lg, valid_dir_cl)                     #On retourne les pions encadrés 
                        p.tour += 1                                                             #On passe au tour suivant 
                    else:                                                   #Sinon
                        print("Merci de choisir un emplacement correct")        #On lui demande de choisir une position correcte

                else:                                                   #Sinon
                    print("Cette emplacement est déjà pris !")              #On lui dis que la case est deja occupé
            else:
                p.tour += 1                                 #Sinon on saute son tour
        else:                                           #Sinon on saute son tour 
            p.tour +=1
            
        
    #Quand la partie prend fin on affiche le tableau final
    pl.affiche(p.tab,pl.dimenssion)
Beispiel #20
0
 def select(self):
     file_name = self.file_name.get()
     if file_name == "academy.py":
         academy(self)
     if file_name == "basicCalc.py":
         basicCalc(self)
     if file_name == "click_counter.py":
         click_counter(self)
     if file_name == "calendar.py":
         calendar(self)
     if file_name == "color_changer.py":
         color_changer(self)
     if file_name == "color_quiz.py":
         color(self)
     if file_name == "disney_princess.py":
         disney_princess(self)
     if file_name == "font_change.py":
         font_change(self)
     if file_name == "hogwarts_house.py":
         hogwarts(self)
     if file_name == "mad_lib.py":
         madlib(self)
     if file_name == "mean_median.py":
         mean_median(self)
     if file_name == "meme_gen.py":
         meme_gen(self)
     if file_name == "menu.py":
         menu(self)
     if file_name == "Periodic_table.py":
         Periodic_table(self)
     if file_name == "rand_num_gen.py":
         rand_num_gen(self)
     if file_name == "spiritAnimal.py":
         spiritAnimal(self)
     if file_name == "surprise.py":
         surprise(self)
     if file_name == "third_grade_quiz.py":
         third_grade_quiz(self)
     if file_name == "wallet.py":
         wallet(self)
Beispiel #21
0
def menu():
    import menu 
    
    nombre= str(input("Ingrese el nombre de la gramatica o AFD\n ")) 
    op = 0
    while op != 4:
        print("=========================================================")
        print("=\t\t 1.   Ver Detalles\t\t\t=") 
        print("=\t\t 2.   Reporte general \t\t\t=") 
        print("=\t\t 3.   Menu Principal\t\t\t=") 
        print("=========================================================")
        op = str(input("Elige una opcion:\n"))       

        if op == '1' :

            detalles(nombre)
            break
        elif op == '2' :
            graph.Pdf()
            break 
        elif op == '3':  
            menu.prueba()
        else:
            menu()
Beispiel #22
0
def login_verificar():

    username1 = user_verificar.get()

    password1 = pass_virificar.get()

    username_entry1.delete(0, END)

    password_entry1.delete(0, END)

    list_of_files = os.listdir(
    )  # este es el algoritmo para verificar que no se repita el log

    if username1 in list_of_files:

        file1 = open(username1, "r")

        verify = file1.read().splitlines()

        if password1 in verify:

            # login_sucess()
            menu()
            # screen.place_forget()
            screen2.destroy()
            # menu.focus_set()
            # menu.grab_set()
            # # menu.menu.wait_window(menu)

        else:

            pass_no_reconocido()

    else:

        user_no_encontrado()
Beispiel #23
0
def main():
    class Error(Exception):
        pass

    class NotFound(Error):
        pass

    scene = "menu"
    scores = getHighScores()

    joysticks = []
    for i in range(pygame.joystick.get_count()):
        joysticks.append(pygame.joystick.Joystick(i))
        joysticks[-1].init()
    joystick_control = False

    #screen = pygame.display.set_mode((1300,700))
    resolution = pygame.display.Info()
    screen = pygame.display.set_mode(
        (resolution.current_w, resolution.current_h), pygame.FULLSCREEN)

    #intro(screen)

    while scene != "Exit":

        try:
            if scene == "Exit":
                pass
            elif scene == "menu":
                scene = menu(screen, joysticks, joystick_control)
            elif scene == "High Scores":
                scene = scoreboards(screen, scores, joysticks,
                                    joystick_control)
            elif scene == "Arcade":
                score = arcade(screen, joysticks, joystick_control)
                if score > scores[-1][0]:
                    name = keyboard(screen, joysticks, joystick_control)
                    scores[-1] = [score, name]
                    scores.sort(reverse=True)
                    screen.fill((0, 0, 0))
                scene = restart(screen, joysticks, joystick_control, score)
            else:
                raise NotFound
        except NotFound:
            scene = Error404(screen, joysticks)

    saveHighScores(scores)
    pygame.display.quit()
Beispiel #24
0
def main():
    logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
    # Assure py3
    assure_py3()
    # Check epics
    logging.info("libca " + str(epics.ca.find_libca()))
    # tn
    os.environ["EPICS_CA_ADDR_LIST"] = "10.0.16.85"
    # lab
    # os.environ["EPICS_CA_ADDR_LIST"] = "10.0.16.92"
    os.environ["EPICS_CA_AUTO_ADDR_LIST"] = "NO"
    logging.info("EPICS_CA_ADDR_LIST" + " " + os.environ['EPICS_CA_ADDR_LIST'])
    logging.info("EPICS_CA_AUTO_ADDR_LIST" + " " +
                 os.environ['EPICS_CA_AUTO_ADDR_LIST'])

    # Get the cli params
    cli_params = menu()
    if cli_params.manual:
        print(open('README.md').read())

    # Interface
    interface = {
        "inventory": cli_params.inventory,
        "network": cli_params.inventory.replace(".", "_net."),
        "plot": cli_params.inventory.replace(".", "_plot."),
        "limits": "inventory/limits.json",
        "pvs": cli_params.pvs,
        "errors": cli_params.inventory.replace(".", "_err.")
    }

    if cli_params.dev:
        for el in interface:
            interface[el] = interface[el].replace(".", "_dev.")

    # declare meta list to log the program progress
    logging.info("cli_params " + str(cli_params))
    logging.info("interface " + str(interface))
    if cli_params.net:
        tnet.main(inventory_jl=interface["inventory"],
                  network_jl=interface["network"],
                  pvs_jl=interface["pvs"])
    if cli_params.plot:
        tplot.main(network_jl=interface["network"], plot_jl=interface["plot"])
    if cli_params.check:
        tcheck.main(network_jl=interface["network"],
                    limits_jl=interface["limits"],
                    output_jl=interface["errors"])
Beispiel #25
0
def guessTheNumber():

   choix = menu()
   choix = int(choix)

   if choix == 1:
      nbAdeviner = random.randint(0, 100)
      jeu(demande_saisie_nb_mystere(1),nbAdeviner,0,100)
   elif choix == 2:
      nbAdeviner = random.randint(0, 1000)
      jeu(demande_saisie_nb_mystere(2),nbAdeviner,0,1000)
   elif choix == 3:
   	  nbAdeviner = random.randint(0, 1000000)
   	  jeu(demande_saisie_nb_mystere(3),nbAdeviner,0,1000000)
   else:
   	  nbAdeviner = random.randint(0, 1000000000000)
   	  jeu(demande_saisie_nb_mystere(4),nbAdeviner,0,1000000000000)
Beispiel #26
0
def main(mode, report, fullscreen):
    if report:
        print "initializing"
    if mode == 2:
        level = "levels/level"
    framerate = 60
    pygame.time.set_timer(pygame.VIDEOEXPOSE, 1000 / framerate)
    screen = pygame.display.set_mode((screen_width, screen_height))
    if fullscreen:
        pygame.display.toggle_fullscreen()
    while mode != -1:
        if mode == 0:
            mode, level = menu(screen)
        elif mode == 1:
            mode = play(screen, level, report)
        elif mode == 2:
            play(screen, level, report)
            return
Beispiel #27
0
def main(mode, report, fullscreen):
	if report:
		print "initializing"
	if mode == 2:
		level = "levels/level"
	framerate = 60
	pygame.time.set_timer(pygame.VIDEOEXPOSE, 1000 / framerate)
	screen = pygame.display.set_mode((screen_width, screen_height))
	if fullscreen:
		pygame.display.toggle_fullscreen()
	while mode != -1:
		if mode == 0:
			mode, level = menu(screen)
		elif mode == 1:
			mode = play(screen, level, report)
		elif mode == 2:
			play(screen, level, report)
			return
Beispiel #28
0
    def multiplayer(self):
        self.perso.reset()
        self.partie = ["Multi", 0]
        self.perso.map = 0
        const.runned = True
        const.input = []
        const.output == ""
        const.host = ask(self, "Enter the IP of the server :").lower()
        thread=threading.Thread(target=client.connect)
        const.input.append("co_perso;"+self.perso.get_char(";"))
        const.input_udp = "set_adr_udp;"+self.perso.nom
        thread.start()
        tps_connect = 0
        cmd = 1
        while const.output == "":
            tps_connect +=1
        if const.output != "Connected":
            cmd = menu(self, const.output, ["Ok"])
            const.output = ""
        else:
            const.output = ""
            const.input.append("get_inv")
            const.input.append("get_mobs")
            while const.output == "":
                tps_connect +=1
            self.perso.inv.empty()
            self.perso.inv.load(const.output)
            const.output = ""
            const.input.append("get_welcome")
            while not cmd in [5,0]:
                const.input.append("set_map;"+str(self.partie[1]))
                const.input.append("get_map;"+str(self.partie[1]))
                const.input.append("get_last_event_map;"+str(self.partie[1]))
                const.input.append("get_last_event")
                while const.map == []:
                    tps_connect +=1
            
                cmd = jeu(self, const.map, self.perso)
                const.map = []
                self.partie[1] = self.perso.map

        const.runned = False
        const.mobs = True
        return cmd
Beispiel #29
0
    def InputSenha(self):
        login_us = self.usuario_entrada.text()
        senhaUs = self.senha_entrada.text()
        verificador = False


        conexao = sqlite3.connect('eh.db')
        cursor = conexao.cursor()
        cursor.execute('SELECT nome FROM usuarios WHERE nome="%s"   ' %login_us )
        resultado1 = cursor.fetchone()

        '''
        x = print('Resultado da busca: %s' %resultado1)
        y = print('Nome usuario: %s' % login_us)
        #print('Senha usuario: %s' % senhaUs)


        if x == y :
            print('resultado dos nomes iguais')
            
        else:
            print('Resultado dos nomes diferentes ')
            

        cursor.execute('SELECT senha FROM usuarios WHERE senha="%s" ' %senhaUs)
        resultado2 = cursor.fetchone()

        w = print('Resultado da senha: %s' %resultado2)
        z = print('Senha campo: %s' %senhaUs)

        if w == z:
            print('Senhas iguais')
            
        else:
            print('Senhas diferentes')
            
        '''
        
        ui = menu()
        ui.setupUi(MainWindow)
Beispiel #30
0
    def InputSenha(self):
        login_us = self.usuario_entrada.text()
        senhaUs = self.senha_entrada.text()
        verificador = False

        conexao = sqlite3.connect('eh.db')
        cursor = conexao.cursor()
        cursor.execute('SELECT nome FROM usuarios WHERE nome="%s"   ' %
                       login_us)
        resultado1 = cursor.fetchone()
        '''
        x = print('Resultado da busca: %s' %resultado1)
        y = print('Nome usuario: %s' % login_us)
        #print('Senha usuario: %s' % senhaUs)


        if x == y :
            print('resultado dos nomes iguais')
            
        else:
            print('Resultado dos nomes diferentes ')
            

        cursor.execute('SELECT senha FROM usuarios WHERE senha="%s" ' %senhaUs)
        resultado2 = cursor.fetchone()

        w = print('Resultado da senha: %s' %resultado2)
        z = print('Senha campo: %s' %senhaUs)

        if w == z:
            print('Senhas iguais')
            
        else:
            print('Senhas diferentes')
            
        '''

        ui = menu()
        ui.setupUi(MainWindow)
Beispiel #31
0
    def screen_main(self, menu_list, title):
        success = True
        try:
            #Begin GUI
            self.stdscr = curses.initscr()
            self.height = self.stdscr.getmaxyx()[0]
            self.width = self.stdscr.getmaxyx()[1]
            curses.noecho()
            curses.cbreak()
            self.stdscr.keypad(1)
            color = color_t()
            color.init_color()
            self.stdscr.nodelay(0)

            #Draw background
            self.stdscr.bkgd(' ', color.get_color(0, color_t.BLUE))
            curses.curs_set(0)
            e = encoder()
            self.stdscr.addstr(
                0, 0, e.convert(title),
                color.get_color(color_t.WHITE, color_t.BLUE) | curses.A_BOLD)
            self.update()

            #Create menu window
            m = menu(self, title)
            m.show_menu(menu_list)

        except:
            success = False
        finally:
            #End GUI
            self.stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()
            if not success:
                traceback.print_exc()
Beispiel #32
0
    def nouvelle_partie(self, nom):
        partie = [nom, 0, 0]
        self.perso.inv.empty()
        self.perso.inv.add(Item(1,1))
        # Copie map std
        i = 0

        while True:
            if not os.path.isdir("data/save/"):
                os.mkdir("data/save/")
            if not os.path.isdir("data/save/"+nom+"/"):
                os.mkdir("data/save/"+nom+"/")
                break
            elif menu(self, "Warning : Erase existing game ?", ["Yes", "No"]) == 1:
                for entry in os.listdir("data/save/"+nom+"/"):
                    os.remove("data/save/"+nom+"/"+entry)
                os.rmdir("data/save/"+nom+"/")
                os.mkdir("data/save/"+nom+"/")
                break
            else:
                nom = ask(self, "New Game] Game's name : ")
                
       
        while open_map("map/std/map"+str(i)) != []:
            save_map("save/"+nom+"/map"+str(i),open_map("map/std/map"+str(i)))
            i = i+1

        # Génération sous-sol
        save_map("save/"+nom+"/map-1", self.gen_map(-1))
       
        # Fichier global
        file = open("data/save/"+nom+"/"+nom, "w")
        file.write("map=0\nid=0\n")
        file.close()
        cine(self, 1)
        return partie
Beispiel #33
0
	def screen_main(self,menu_list,title):
		success = True
		try:
			#Begin GUI
			self.stdscr = curses.initscr()
			self.height = self.stdscr.getmaxyx()[0]
			self.width = self.stdscr.getmaxyx()[1]
			curses.noecho()
			curses.cbreak()
			self.stdscr.keypad(1)
			color = color_t()
			color.init_color()
			self.stdscr.nodelay(0)
			
			#Draw background
			self.stdscr.bkgd(' ',color.get_color(0,color_t.BLUE))
			curses.curs_set(0)
			e = encoder()
			self.stdscr.addstr(0,0,e.convert(title),
				color.get_color(color_t.WHITE,color_t.BLUE) | curses.A_BOLD)
			self.update()
			
			#Create menu window
			m = menu(self,title)
			m.show_menu(menu_list)

		except:
			success = False
		finally:
			#End GUI
			self.stdscr.keypad(0)
			curses.echo()
			curses.nocbreak()
			curses.endwin()
			if not success:
				traceback.print_exc()
def image_edit(filename, quick="N", image_path="pictures/"):
    image_file = Image.open(image_path + "downloaded/" + filename)
    if image_file.width > settings.img_final_sizes[0]\
            or image_file.height > settings.img_final_sizes[1]:
        image_file.thumbnail(settings.img_final_sizes)
    image_file.save(image_path + filename, "PNG")
    image_file.close()

    print("Image has been edited")
    if quick != "Y":
        delete_dowloaded = input("Delete downloaded file (Y/N): ")
        if delete_dowloaded == "y":
            os.remove(image_path + "downloaded/" + filename)
            print("Downloaded file deleted")
        next_step = input("Next to outline (Y/N): ")
        if next_step == "y":
            return image_outline(filename)
        else:
            return menu.menu()
    else:
        os.remove(image_path + "downloaded/" + filename)
        print("Downloaded file deleted")
        return image_outline(filename, quick="Y")
    return menu()
Beispiel #35
0
from game import *
from menu import *


def go_to_game():

    ans_human = menu('Введите кол-во игроков (людей)',
                     ['1. 1-игрок', '2. 2-игрока', '0. Без людей'],
                     ['1', '2', '0'])
    ans_computer = menu('Введите кол-во игроков (компьютеров)',
                        ['1. 1-игрок', '2. 2-игрока', '0. Без компьютеров'],
                        ['1', '2', '0'])
    if int(ans_human) + int(ans_computer) == 0:
        print('Нужен хотя-бы один игрок, хоть сам с собой')
        return
    game(int(ans_human), int(ans_computer))


while True:

    print('***', "ИГРА ЛОТО", '***')
    ans = menu('ГЛАВНОЕ МЕНЮ', ['1. Начать игру', '0. Выход'], ['1', '0'])
    if ans == '1':
        go_to_game()
    elif ans == '0':
        break
Beispiel #36
0
def main():

    pygame.init()

    pygame.display.set_caption('Super Mario Bros.')
    pygame.display.set_icon(pygame.image.load(os.path.join('data', 'icon.gif')))
    screen = pygame.display.set_mode(SCREENRECT.size, HWSURFACE|HWPALETTE|DOUBLEBUF)
    pygame.mouse.set_visible(0)

    font = BitmapFont("BMP font.bmp",8,9,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ.,-?! ")

    background = load_background('Overworld Background.png')
    nintendo_logo = load_image('Nintendo Logo.png')
    lives_icon = load_image('Lives Icon.png')
    castle = load_tile('Castle.png')
    castle2 = load_tile('Castle Right Half.png')
    coin_imgs = []
    coin_imgs.append(load_image('Coin 1.png'))
    coin_imgs.append(load_image('Coin 2.png'))
    coin_imgs.append(load_image('Coin 3.png'))
    coin_imgs.append(load_image('Coin 4.png'))


    Player.containers = playerlayer
    Player.sprites = sprites
    Player.platforms = platforms
    Player.platforms3 = platforms3
    PlayerWin.containers = outerlayer, sprites
    PlayerWin.platforms = allplatforms
    PlayerWin.flags = flags
    PlayerDie.containers = outerlayer, sprites
    Ground.containers = middlelayer, sprites, topplatforms, platforms, allplatforms
    Object.containers = middlelayer, sprites, platforms, allplatforms
    Object2.containers = middlelayer, sprites, middleplatforms, allplatforms
    Object3.containers = middlelayer, sprites, platforms2, allplatforms
    Object4.containers = middlelayer, sprites, platforms3, allplatforms
    Scenery.containers = innerlayer, sprites
    QuestionBlock.containers = middlelayer, sprites, questionblocks, platforms, allplatforms
    Goomba.containers = outerlayer, sprites, goombas
    Goomba.platforms = allplatforms
    Goomba.dirpoints = dirpoints
    Koopa.containers = middlelayer, sprites, koopas
    Koopa.platforms = allplatforms
    Koopa.dirpoints = dirpoints
    Goombadie.containers = middlelayer, sprites
    BaddieSpawnPoint.containers = innerlayer, sprites
    BaddieBoundary.containers = sprites, dirpoints
    Mushroom.containers = outerlayer, sprites, mushrooms
    Mushroom.platforms = allplatforms
    CoinUp.containers = middlelayer, sprites
    Flag.containers = middlelayer, sprites, flags
    Flag.platforms = allplatforms
    BrickParticle.containers = outerlayer, sprites
    Koopashell.containers = middlelayer, sprites, shells
    Koopashell.platforms = allplatforms
    FireFlower.containers = innerlayer, sprites, fireflowers
    FireFlower.platforms = allplatforms
    Fireball.containers = middlelayer, sprites, fireballs
    Fireball.platforms = allplatforms
    Rotodisk.containers = outerlayer, rotodisks, sprites

    clock = pygame.time.Clock()

    coin_img = coin_imgs[FRAME/4%4]
    player = Player(NAME, '')
    die = PlayerDie(player)
    win = PlayerWin(player)
    global LEVEL, SCORE, LIVES, TIME, WORLD, STATE, DEAD, COINS, FRAME, BG, FULLSCREEN, NAME, LEVEL_UP,joyLeft,joyRight
    STATE = 1
    clouds = []
    clouds.append(Cloud('Cloud Medium.png'))
    clouds.append(Cloud('Cloud Small.png'))
    clouds.append(Cloud('Cloud Large.png'))
    clouds.append(Cloud('Cloud Medium.png'))
    clouds.append(Cloud('Cloud Small.png'))
    clouds.append(Cloud('Cloud Small.png'))
    clouds.append(Cloud('Cloud Medium.png'))

    highscore = int(open(highscore_f).read())

    the_level = load_level(LEVEL)
    music = load_music('World 1.ogg')
    clearlvl(player, sprites)


    menu(screen, player, sprites, music)
    LEVEL = 1

    while 1:

        Koopashell.player = player

        innerlayer.clear(screen, background)
        innerlayer.update()

        middlelayer.clear(screen, background)
        middlelayer.update()

        outerlayer.clear(screen, background)
        outerlayer.update()


        clock.tick(FPS)


        event = pygame.event.poll()

        keystate = pygame.key.get_pressed()
        defaultkeys1 = handle_input1()
        defaultkeys2 = handle_input2(keystate)

        if event.type == QUIT:
            sys.exit()
        if (event.type == KEYDOWN and event.key == K_ESCAPE) or (event.type == JOYBUTTONDOWN and event.button == 8):
            menu(screen, player, sprites, music)

        if ((event.type == KEYDOWN and event.key == K_z) or (event.type == JOYBUTTONDOWN and event.button == 2)) and player.jumping == False and player.alive():
            player.jump_speed = player.jump_power
            player.jumping = True
            player.y -= 5
            jump_sound.play()
        if ((event.type == KEYDOWN and event.key == K_x) or (event.type == JOYBUTTONDOWN and event.button == 7)) and player.alive() and STATE == 3:
            Fireball(player)
            player.throw_timer = 5

        if event.type == JOYBUTTONUP and event.button == 3 :
            joyRight,joyLeft = 0,0

        if event.type == JOYBUTTONUP and event.button == 0 :
            joyRight,joyLeft = 0,0
        
        if event.type ==JOYBUTTONDOWN and event.button == 3:
            joyRight = 1
            joyLeft = 0
        if event.type ==JOYBUTTONDOWN and event.button == 0:
            joyLeft = 1
            joyRight = 0
        moving = joyRight - joyLeft
        if player.alive():
            player.move(moving)
            screenscroll(player, sprites, moving)

            for c in clouds:
                c.xpos -= int(player.speed)

        if player.jump_speed > player.max_fall_speed and (keystate[K_z]):
            player.jump_speed -= player.keydown_fall_speed
        if player.jump_speed > player.max_fall_speed and not (keystate[K_z]):
            player.jump_speed -= player.keyup_fall_speed

        for questionblock in pygame.sprite.spritecollide(player, questionblocks, 0):
            if player.jump_speed > 0 and (player.rect.top + 18 > questionblock.rect.bottom >= player.rect.top):
                player.jump_speed = -1
                player.y += questionblock.rect.bottom - player.rect.top
                if not questionblock.hit and questionblock.type == 1:
                    COINS += 1
                    SCORE += 25
                    coin_sound.play()
                    CoinUp(questionblock)
                    questionblock.hit = True
                if not questionblock.hit and questionblock.type == 2:
                    questionblock.hit = True
                    if STATE == 1:
                        Mushroom(questionblock.rect.center)
                    else:
                        FireFlower(questionblock.rect.center)
                    item_sound.play()
                questionblock.hit = True
                player.jump_speed = -1
                player.rect.top = questionblock.rect.bottom
                questionblock.image = load_tile('Empty Block.png')
                questionblock.bounce()

        for platform in platforms:  
            if player.rect.colliderect(platform.rect):
                if player.jump_speed > 0 and (player.rect.top + 18 > platform.rect.bottom >= player.rect.top):
                    if platform.hittable:
                        platform.bounce()
                        if STATE > 1:
                            brick_sound.play()
                            platform.kill()
                            BrickParticle(platform.rect.topleft, -1, -2, 0, 2)
                            BrickParticle(platform.rect.topright, 1, -2, 0, 2)
                            BrickParticle(platform.rect.bottomleft, -1, 2, 0, 2)
                            BrickParticle(platform.rect.bottomright, 1, 2, 0, 2)
                if platform.landable:
                    player.topwallcheck(platform.rect)
                if platform.hittable:
                    player.bottomwallcheck(platform.rect)
                player.sidewallcheck(platform.rect, moving)
                if player.speed > 0 or player.speed < 0 and \
                   (platform.rect.left > player.rect.left or platform.rect.right < player.rect.right):
                    if player.rect.bottom > platform.rect.top and player.rect.top < platform.rect.bottom - 16:
                        for c in clouds:
                            c.xpos += int(player.speed)
        for platform in middleplatforms:
            if player.rect.colliderect(platform.rect):
                if platform.landable:
                    player.topwallcheck(platform.rect)
                player.sidewallcheck(platform.rect, moving)
                if player.speed > 0 or player.speed < 0 and \
                   (platform.rect.left > player.rect.left or platform.rect.right < player.rect.right):
                    if player.rect.bottom > platform.rect.top and player.rect.top < platform.rect.bottom - 16:
                        for c in clouds:
                            c.xpos += int(player.speed)
        for platform in platforms2:
            if player.rect.colliderect(platform.rect):
                if platform.landable:
                    player.topwallcheck(platform.rect)
                player.sidewallcheck(platform.rect, moving)
                if platform.hittable:
                    player.bottomwallcheck(platform.rect)
                if player.speed > 0 or player.speed < 0 and \
                    (platform.rect.left > player.rect.left or \
                    platform.rect.right < player.rect.right):
                    if player.rect.bottom > platform.rect.top and player.rect.top < platform.rect.bottom - 16:
                        for c in clouds:
                            c.xpos += int(player.speed)

        for platform in platforms3:
            if player.rect.colliderect(platform.rect):
                if player.jump_speed < 0 and \
                   (player.rect.bottom - 16 < platform.rect.top <= player.rect.bottom):
                    player.rect.bottom = platform.rect.top
                    player.jump_speed = -platform.yspeed
                    player.jumping = False
                player.sidewallcheck(platform.rect, moving)
                player.bottomwallcheck(platform.rect)
                    
                if player.speed > 0 or player.speed < 0 and \
                    (platform.rect.left > player.rect.left or platform.rect.right < player.rect.right):
                    if player.rect.bottom > platform.rect.top and player.rect.top < platform.rect.bottom - 16:
                        for c in clouds:
                            c.xpos += int(player.speed)

        if player.jump_speed < 1 and player.jumping == True:
            for g in pygame.sprite.spritecollide(player, goombas, 0):
                if player.rect.bottom >= g.rect.top + 10 and player.alive():
                    stomp_sound.play()
                    player.jump_speed = 9
                    SCORE += 100
                    g.kill()
                    Goombadie(g)
            for k in pygame.sprite.spritecollide(player, koopas, 0):
                if player.rect.bottom >= k.rect.top + 5 and player.alive():
                    stomp_sound.play()
                    player.jump_speed = 9
                    SCORE += 100
                    k.kill()
                    Koopashell(k)
        else:
            #if player.alive():
                for g in pygame.sprite.spritecollide(player, goombas, 0):
                    if STATE == 1:
                        DEAD = True
                        if player.alive():
                            LIVES -= 1
                            g.kill()
                            die = PlayerDie(player)
                            die_sound.play()
                        music.stop()
                    player.kill()
                    playery = player.rect.top
                    if not DEAD:
                        player = Player(NAME, '')
                        player.rect.top = playery
                        if STATE == 2:
                            player.transferimgs = load_images(NAME + ' stand2.png', 'Super ' + NAME + ' Stand.png')
                        if STATE == 3:
                            player.transferimgs = load_images(NAME + ' stand2.png', 'Fiery ' + NAME + ' Stand.png')
                        player.transfer()
                        pd_sound.play()
                    if STATE == 2 or STATE == 3:
                        STATE = 1
                for r in spritecollide_pp(player, rotodisks, 0):
                    if STATE == 1:
                        DEAD = True
                        if player.alive():
                            LIVES -= 1
                            die = PlayerDie(player)
                            die_sound.play()
                        music.stop()
                    player.kill()
                    playery = player.rect.top
                    if not DEAD:
                        player = Player(NAME, '')
                        player.rect.top = playery
                        if STATE == 2:
                            player.transferimgs = load_images(NAME + ' stand2.png', 'Super ' + NAME + ' Stand.png')
                        if STATE == 3:
                            player.transferimgs = load_images(NAME + ' stand2.png', 'Fiery ' + NAME + ' Stand.png')
                        player.transfer()
                        pd_sound.play()
                    if STATE == 2 or STATE == 3:
                        STATE = 1
        for g in pygame.sprite.groupcollide(goombas, fireballs, 1, 1):
            Goombadie(g)
            stomp_sound.play()

        for mushroom in pygame.sprite.spritecollide(player, mushrooms, 1):
            pu_sound.play()
            SCORE += 1000
            if STATE == 1:
                player.kill()
                playery = player.rect.top
                player = Player(NAME, 'Super ')
                player.rect.top = playery - 16
                player.transfer()
                pu_sound.play()
                STATE = 2
        for fireflower in pygame.sprite.spritecollide(player, fireflowers, 1):
            pu_sound.play()
            SCORE += 1000
            if STATE <= 2:
                player.kill()
                playery = player.rect.top
                player = Player(NAME, 'Fiery ')
                player.rect.top = playery
                player.transfer()
                pu_sound.play()
                STATE = 3

        if pygame.sprite.spritecollide(player, flags, 0):
            if player.alive():
                player.kill()
                win = PlayerWin(player)
                music.stop()
                win_music.play()
        for c in pygame.sprite.spritecollide(player, coins, 1):
            coin_sound.play()
            COINS += 1

        for g in pygame.sprite.groupcollide(goombas, shells, 1, 0):
            Goombadie(g)
            stomp_sound.play()
 
        if LEVEL_UP == True and LEVEL > 0:
            clearlvl(player, sprites)
            DEAD = False
            intermission(screen, LEVEL, WORLD, LIVES, SCORE, TIME, COINS, FRAME, coin_imgs, coin_img)
            if STATE == 1:
                player = Player(NAME, '')
            if STATE == 2:
                player = Player(NAME, 'Super ') 
            if STATE == 3:
                player = Player(NAME, 'Fiery ') 
            LEVEL_UP = False
            the_level = load_level(LEVEL)
            TIME = 201
            music = load_music('World %d.ogg' % the_level.world).play(-1)

        if not player.alive() and not die.alive() and not win.alive():
            if LIVES > 0:
                LEVEL_UP = True

        screen.blit(background, (0, 0))
        TIME -= 0.02
        BG = the_level.world
        if BG == 1:
            screen.fill((112, 168, 255))
            for c in clouds:
                c.draw(screen)
        if BG == 2:
            screen.fill((0, 0, 0))
        if BG == 3:
            screen.fill((112, 168, 255))
            for c in clouds:
                c.draw(screen)
        if BG == 4:
            screen.fill((0, 0, 0))
        if TIME <= 0:
            if player.alive():
                die = PlayerDie(player)
                music.stop()
                die_sound.play()
                player.kill()
            TIME = 0
        if player.rect.top >= 520 and player.alive():
            player.kill()
            music.stop()
            die_sound.play()
            die = PlayerDie(player)
            STATE = 1
            LIVES -= 1
        FRAME += 1

        dirty = innerlayer.draw(screen)
        middlelayer.draw(screen)
        for flag in flags:
            screen.blit(castle, (flag.rect.right + 45, flag.rect.bottom - castle.get_height() + 32))
        outerlayer.draw(screen)
        for flag in flags:
            screen.blit(castle2, (flag.rect.right + 45, flag.rect.bottom - castle.get_height() + 32))

        if player.alive():
            screen.blit(player.image, (player.rect[0] - 8, player.rect[1]))

        ren = font.render(str(NAME))
        screen.blit(ren, (40, 25))
        ren = font.render('%06d' % SCORE)
        screen.blit(ren, (40, 40))
        ren = font.render('X%02d' % COINS)
        screen.blit(ren, (190, 40))
        ren = font.render('WORLD')
        screen.blit(ren, (280, 25))
        ren = font.render('%d-%d' % (WORLD, LEVEL))
        screen.blit(ren, (295, 40))
        ren = font.render('TIME')
        screen.blit(ren, (410, 25))
        ren = font.render('%03d' % TIME)
        screen.blit(ren, (420, 40))
        coin_img = coin_imgs[FRAME/4%4]
        screen.blit(coin_img, (165, 30))
        if SCORE > highscore:
            highscore = SCORE
            open(highscore_f, 'w').write(str(SCORE))

        Koopashell.player = player

        if die.life <= 1 and die.alive() and LIVES == 0:
            gameover.play()

        if not die.alive():
            if LIVES <= 0:
                screen.fill((0, 0, 0))
                ren = font.render('GAME OVER')
                screen.blit(ren, (SCREENRECT.centerx - ren.get_width()/2, SCREENRECT.centery - ren.get_height()))

        pygame.display.update(dirty)
        pygame.display.flip()
 def setUp(self):
     db.delete('MenuItems', where='1=1')
     self.menued = menu()
Beispiel #38
0
from menu import *

menu()
    del remoteObj
    remoteObj = LgRemote(arduinoPort)


def exitFunction():
    sys.exit()


def menu():
    options = [("Set COM port", setComPort),
               ("Basic menu", mainMenu.basicMenu.open),
               ("Service menu", mainMenu.serviceMenu.open),
               ("Settings/Menu menu", mainMenu.settingsMenu.open),
               ("Numpad menu", mainMenu.numpadMenu.open),
               ("Player menu", mainMenu.playerMenu.open),
               ("TV menu", mainMenu.tvMenu.open),
               ("Misc menu", mainMenu.miscMenu.open), ("Exit", exitFunction)]
    mainMenu.set_options(options)


if __name__ == '__main__':
    menu()
    basicMenu(mainMenu, remoteObj)
    serviceMenu(mainMenu, remoteObj)
    settingsMenu(mainMenu, remoteObj)
    numpadMenu(mainMenu, remoteObj)
    playerMenu(mainMenu, remoteObj)
    miscMenu(mainMenu, remoteObj)
    tvMenu(mainMenu, remoteObj)
    mainMenu.open()
Beispiel #40
0
#!/bin/python3
# -*-coding:Utf-8 -*

from menu import * #on importe les modules de menu et jeu
from game import *


while True:

    choice = menu() #on affiche le menu et demande quoi faire

    if choice == 1: #option1 : on affiche les regles
        menuSeeRules()

    if choice == 2: #option2 : on lance le jeu
        game()

    if choice == 3: #option3 : on  quitte le jeu
        MenuQuit()
    
    continue
Beispiel #41
0
            self.marcador= str(self.valor) +  " - " + str(self.valor2)
        cancha.display.blit(self.imagen,(self.rect))

cronometro=reloj()                  
c = Capture()
c.calibrate()
persona=personaje()
persona2=personaje_2()
pelota=bola(100,150)
clock = pygame.time.Clock()
cancha=fondo()
text = Text()
caja1=cajas()
quit = False
cur=cursor(100,15)
men=menu(140,40)
def menu_principal():
    seleccion=True
    while seleccion==True:
        for event in pygame.event.get():
           pass 

        cancha.display.fill(FONDO)
        valor=cur.actualizar(cancha)
        men.actualizar(text)
        if pygame.key.get_pressed()[pygame.K_RETURN]:

            if valor==1:
                juego()
            if valor==2:
                calibracion()
Beispiel #42
0
def editeur(app, map, nom):

    input = Input()
    
    fond = Element()
    fond.changer_image(pygame.image.load(const.path_fond1).convert())

    pointeur = element.Element()
    pointeur.changer_image(pygame.image.load("img/pointeur.png").convert_alpha())

    b_txt = []
    b_txt = write(app, "()", 0, 0)
    w_txt = []
    w_txt = write(app, "()", 0, 0, (255,255,255))
    
    blocs = []
    blocs.append(Porte(0,0))
    blocs.append(Bloc(1))
    blocs.append(Bloc(5))
    blocs.append(Bloc(6))
    blocs.append(Lava())
    blocs.append(BlocDanger(4,1))
    blocs.append(Torch(13))
    blocs.append(Terre(7))

    choix=0
    while not input.quit: 
        input.update_event(app)
        pointeur.move_el(-pointeur.x+input.mouse[0], -pointeur.y+input.mouse[1])
        if input.key[K_ESCAPE]:
            input.key[K_ESCAPE] = 0
            cmd = menu(app, "Edit Level", ["Save Level","Save Level as", "Load Level","Try Level", "Quit"])
            if cmd == 2:
                nom = ask(app, "Save as :")
            if cmd == 2 or cmd == 1:
                save_map("map/custom/"+nom, map)
            elif cmd == 3:
                nom = ask(app,"Load Level] Level's name : ")
                map = open_map("map/custom/"+nom)
                cmd =1
            elif cmd == 4:
                jeu(app, map, app.perso)
            elif cmd == 0:
                return 5
        if input.mousebuttons[4]:
            choix-=1
            if choix < 0:
                choix = len(blocs)-1
            input.mousebuttons[4] = 0
        if input.mousebuttons[5]:
            choix+=1
            if choix > len(blocs)-1:
                choix = 0
            input.mousebuttons[5] = 0
        if input.mousebuttons[1]:
            input.mousebuttons[1] = 0
            for i in map:
                if (i.x == input.get_mouse_bloc()[0] and i.y == input.get_mouse_bloc()[1]) and choix != 6:
                    map.remove(i)
            bloc = copy.copy(blocs[choix])
            bloc.move_el(-bloc.x+input.get_mouse_bloc()[0], -bloc.y+input.get_mouse_bloc()[1])
            map.append(bloc)
        if input.mousebuttons[3]:
            input.mousebuttons[3] = 0
            for i in map:
                if (i.x == input.get_mouse_bloc()[0] and i.y == input.get_mouse_bloc()[1]):
                    map.remove(i)

            
        b_txt = []
        b_txt = write(app, str(input.get_mouse_bloc())+"\n"+nom, 0, 0)
        w_txt = []
        w_txt = write(app, str(input.get_mouse_bloc())+"\n"+nom, 2, 2, (255,255,255))
        app.blit(fond)
        for i in map:
            app.blit(i)
        for i in w_txt:
            app.blit(i)
        for i in b_txt:
            app.blit(i)
        blocs[choix].move_el(-blocs[choix].x+pointeur.x+25, -blocs[choix].y+pointeur.y+25) 
        app.blit(blocs[choix])
        app.blit(pointeur)
        app.flip()

    return 0
Beispiel #43
0
import pygame
from menu import *
from intro import *
from juego import *
import sys

ventana_info = {
    "ancho":  1080,
    "alto":   720,
    "titulo": "titulo del juego",
    "color_fondo": (10,10,10) ## casi negro
}

Game_over = False


while Game_over == False:
    intro(ventana_info)   
    menu(ventana_info) 
    juego(ventana_info)


Beispiel #44
0
def run(): 
    menu(plot3d,calculPoints(readParameters()))
Beispiel #45
0
def pausa():
	pygame.init()
	
	#DEFINICAO DA TELA
	screen = pygame.display.set_mode((screen_width,screen_height), 0, 32)
	pygame.display.set_caption("Fire shot")
	
	#definicao da imagem de fundo
	
	fundo_pausa = pygame.image.load('imagens'+ sep +"pausa" + sep + "fundo_pausa.png")
	icon = pygame.image.load('imagens'+ sep +"menu" + sep + "icon.bmp")
	pygame.display.set_icon(icon)
	fundo_pausa_size = fundo_pausa.get_size()
	fundo_pausa_position = [150,60]
	
	#DEFINICOES DOS BOTOES DO PAUSA
	#definicao do botao voltar
	botoes_voltar = [pygame.image.load("imagens" + sep+ 'pausa'+ sep + "voltar_pausa" + str(i) + \
	".png").convert_alpha() for i in xrange(2)]
	botao_voltar = botoes_voltar[0]
	voltar_size = botao_voltar.get_size()
	voltar_position = (350,150)
	
	#definicao do botao menu principal
	botoes_menu = [pygame.image.load("imagens" + sep+ 'pausa'+ sep + "menu_principal" + str(i) + \
	".png").convert_alpha() for i in xrange(2)]
	botao_menu = botoes_menu[0]
	menu_size = botao_menu.get_size()
	menu_position = (330,400)
	
	while True:
			for event in pygame.event.get():
					if event.type == QUIT:
							exit
			#Chamada das teclas
			pressed_keys = pygame.key.get_pressed()
			
			pressed = False
			#CHAMADA DA UTILIZACAO DO MOUSE
			mouse_position = pygame.mouse.get_pos()
			mouse_pressionado = pygame.mouse.get_pressed()
			
			#escolha do botao voltar	
			if voltar_position[0] <= mouse_position[0] <= voltar_position[0] + voltar_size[0] \
			and voltar_position[1] <= mouse_position[1] <= voltar_position[1] + voltar_size[1]or pressed_keys[K_v]:
				botao_voltar = botoes_voltar[1]
				
				if mouse_pressionado[0]:
					break
				
			else: botao_voltar = botoes_voltar[0]
			
			#escolha do botao menu principal	
			if menu_position[0] <= mouse_position[0] <= menu_position[0] + menu_size[0] \
			and menu_position[1] <= mouse_position[1] <= menu_position[1] + menu_size[1]or pressed_keys[K_v]:
				botao_menu = botoes_menu[1]
				
				if mouse_pressionado[0]:
					menu()
				
			else: botao_menu = botoes_menu[0]
			
			screen.blit(fundo_pausa, fundo_pausa_position)
			screen.blit(botao_voltar, voltar_position)
			screen.blit(botao_menu, menu_position)
			pygame.display.update()
Beispiel #46
0
# Load fonts
fonts = {
	"main": loadCFont("main.png", 20, 16, 36, size=1.8),
	"pickups": loadCFont("pickup.png", 10, 12, 10),
	"ticks": loadCFont("ticks.png", 4, 17 , 8),
}

# Begin main loop
running = True
while running:
	# Start by playing the title screen music
	playMusic("titleScreenLoop.ogg", intro="titleScreenIntro.ogg")

	# Begin menu
	characterType, controls, floorSeed = menu(screen, jController, sounds,nextSong, changeSong)

	# Floor setup
	seed(floorSeed)

	# Define current time
	currTime = 0

	# Define clock (mainly for FPS)
	clock = time.Clock()

	# Play the choir noise when the user chooses a level
	# and show the random symboly 
	playMusic("titleScreenJingle.ogg")
	showSymbol(screen, 4, randint(0, 55), textures)
Beispiel #47
0
def main():
    #Initialize stuff
	pygame.init()
	screen = pygame.display.set_mode((globals.SCREEN_W, globals.SCREEN_H),)# FULLSCREEN)
	pygame.display.set_caption('PyClimb')
	pygame.mouse.set_visible(0) #hide the mouse
	clock = pygame.time.Clock() #initialize clock
		
	buffer = pygame.Surface(screen.get_size()) # create our buffer
	buffer = buffer.convert()
	buffer.fill((250, 250, 250))
	

	# set up stuff
	world = ""
	player = ""
	
	textbuffer = ""
	globals.cursor = load_image("pointer.png")
	while not globals.done:
		clock.tick(60) #max out at 60 fps
	
		if(globals.menu):
			menu(screen, buffer, clock) #do the menu drawing
			
			
		
		
			
		else: 
		#	globals.loop = not globals.loop
			#init_game(world) # set up game according to gameoptions, this will only be run once
			if not globals.gameinit:
				
				intro4 = load_image("intro4.jpg")
				buffer.blit(intro4, (0,0))
				if pygame.font:
					font = pygame.font.Font(None, 70)
					text = font.render(str("Loading............."), 1, (0, 10, 10))
					buffer.blit(text, (globals.SCREEN_W/2-500,globals.SCREEN_H-75))
				
				screen.blit(buffer, (0, 0))	
				pygame.display.update()
				
				world = World()
				player = Player()
				
				globals.gameinit = 1
				globals.onmenu =0
				globals.initing = 0
			#handle input, do logic calculations, draw, and cleanup
			handle_input(world, player, screen) # handles mouse and keys	
			
			
			player.update(world)
			world.update(player)
			#fill the buffer
			buffer.fill((200, 200, 250)) # fill the buffer
			#
			#draw the world first
			buffer.blit(world.buffer, (0,0))
			
	
				
			#draw player stuff
			buffer.blit(player.image, (player.x_pos, player.y_pos))
			
			
				
			
			
	
			for i in globals.rocks:
					buffer.blit(i.image, (i.x_pos, i.y_pos))	
					
			#draw them
			
		#for i in globals.powerups:
			
			#if(i.type == 1 and i.y_pos > world.view_y):
			#	buffer.blit(i.image, (i.x_pos, i.y_pos - world.view_y))
			#	pygame.draw.circle(buffer, (0,255,255), (i.x_pos+14, i.y_pos+29), 30, 2)
			#if(i.type == 2 and i.y_pos > world.view_y):
			#	buffer.blit(i.image, (i.x_pos, i.y_pos - world.view_y ))
			#	pygame.draw.circle(buffer, (0,255,255), (i.x_pos+ 14, i.y_pos +29), 30, 2)
			
			
			for i in globals.snowflakes: # SNOW! With relativistic  effects :D
				buffer.blit(i.snowflake, (i.x_pos, i.y_pos))		
			#draw player stuff
			if(player.percentage > 0):
				buffer.blit(player.getBar(), (10, 10)) 
				pygame.draw.rect(buffer, (255,255,255), (10, 10, 300, 10), 2)
			else:
				globals.gamelost = 1
				break
			
			pygame.draw.line(buffer, (0,255,0), (globals.SCREEN_W - 20, 85), ( globals.SCREEN_W - 20, globals.SCREEN_H - 80), 8)
			length = globals.SCREEN_H-130
			x = float(world.view_y)/float(world.height)
			
			
			pygame.draw.rect(buffer,(255, 0, 0), (globals.SCREEN_W-23, int(x*length)+80, 8, 5))
						
				
			for i in globals.bullets:
				pygame.draw.line(buffer, (255, 255, 0), (i.fx+i.x, i.fy+i.y), (i.bx+i.x, i.by+i.y))
		
			#buffer.blit(load_image("enemy.png"), (100, 100))
			
			
			
			# ak ammo and gun
			if(player.guntype == 2 and not player.akpouch==[]): #he's got an AK, corrected comparison prob
				
				for i in range(player.akpouch[player.akpouchclips]):
					buffer.blit(player.akammo, (20+15*i, globals.SCREEN_H -125))
				
				buffer.blit(player.akclip, (20, globals.SCREEN_H -200))
				if pygame.font:
					font = pygame.font.Font(None, 50)
					text = font.render(" X "+str(player.akpouchclips), 1, (0, 10,10))
					
					buffer.blit(text, (45, globals.SCREEN_H -180))
			#####		
			
			# handgun ammo and gun
			if(player.guntype == 1 and not player.handgunpouch==[]): #a lowly handgun
				for i in range(player.handgunpouch[player.handgunclips]):
					buffer.blit(player.handgunammo, (20+15*i, globals.SCREEN_H -100))
				
				buffer.blit(player.m9clip, (20, globals.SCREEN_H - 160))
				if pygame.font:
					font = pygame.font.Font(None, 50)
					text = font.render(" X "+str(player.handgunclips), 1, (0, 10, 10))
					buffer.blit(text, (45, globals.SCREEN_H -150))
			#####
			
			if pygame.font:
					font = pygame.font.Font(None, 50)
					text = font.render(str(globals.points), 1, (255, 255, 255))
					buffer.blit(text, (globals.SCREEN_W-100,25))
					
			#fps
			if pygame.font:
				font = pygame.font.Font(None, 20)
				text = font.render(str(clock.get_fps()), 1, (255, 255, 255))
				textpos = text.get_rect(centerx=buffer.get_width()/2)
				buffer.blit(text, (globals.SCREEN_W/2-100,0))
			#mouse?
			if(globals.cursorvisible):
				buffer.blit(globals.cursor, pygame.mouse.get_pos())
			
		screen.blit(buffer, (0, 0))	
		pygame.display.update()
		cleanup(0) # cleanup stuff like keypresses queue
	globals.donemenu = 1	
	if(done(screen, buffer, clock)): #done
		main()
Beispiel #48
0
    def main(self):
        cmd = 1
        while cmd:
            cmd =  menu(self, "Main Menu", ["Play", "Edit Level", "Quit"])
            if cmd == 2:
                self.perso.reset()
                self.perso.set_org_color()
                self.partie = ["Gen", 0]
                self.perso.map = 0
                cmd = menu(self, "Edit Level", ["New level", "Load level"])
                if cmd == 1:
                    cmd = editeur(self, [], "Unnamed")
                elif cmd == 2:
                    nom = ask(self, "Edit Level] Level's name :")
                    cmd = editeur(self, open_map("map/custom/"+nom), nom)
            elif cmd == 1:
                if not os.path.isdir("data/perso/"):
                    os.mkdir("data/perso/")
                characters = os.listdir("data/perso")[:5]
                characters = ["[ "+i+" ]" for i in characters]
                while len(characters) < 5:
                    characters.append("--Empty--")
                characters.append("Cancel")
                cmd = menu(self, "Choose a Character", characters)
                
                if cmd > len(os.listdir("data/perso/")) and cmd != 6:
                    self.perso.set_org_color()
                    self.perso.nom = ask(self, "Enter a name for the Character")
                    while cmd != 6:
                        cmd = menu(self, "Choose "+self.perso.nom+"'s colors", ["Shirt", "Pants", "Hair", "Skin", "Other", "Done"], self.perso)
                        if cmd != 6:
                            menu_color(self, cmd-1, self.perso)
                    self.perso.save()
                elif cmd < 6:
                    self.perso.load(os.listdir("data/perso")[cmd-1])
                    cmd =  menu(self, "Play", ["Single Player", "Multi Player", "Delete Character", "Edit Character", "Cancel"], self.perso)
                    if cmd == 1:
                        cmd =  menu(self, "Single Player", ["Entering the Tower !", "Play Custom Level", "Cancel"], self.perso)
            
                        if cmd == 1:
                            if not os.path.isdir("data/save"):
                                os.mkdir("data/save/")
                            saves = os.listdir("data/save")[:5]
                            saves = ["[ "+i+" ]" for i in saves]
                            while len(saves) < 5:
                                saves.append("--Empty--")
                            saves.append("Cancel")
                            cmd = menu(self, "Choose a Game", saves)
                            if cmd < 6:
                                self.perso.reset()
                                if cmd > len(os.listdir("data/save/")) and cmd != 6:
                                    self.partie = []
                                    self.partie = self.nouvelle_partie(ask(self, "New Game] Game's name : "))
                                else:
                                    self.partie = self.charger_partie(os.listdir("data/save")[cmd-1])
                                self.perso.map = self.partie[1]
                                self.perso.id_porte = self.partie[2]
                                cmd = 1
                                while open_map("save/"+self.partie[0]+"/map"+str(self.partie[1])) != [] and cmd == 1:
                                    cmd = jeu(self, open_map("save/"+self.partie[0]+"/map"+str(self.partie[1])), self.perso)
                                    self.partie[1] = self.perso.map
                                    if self.partie[1] < 0:
                                        if open_map("save/"+self.partie[0]+"/map"+str(self.partie[1])) == []:
                                            save_map("save/"+self.partie[0]+"/map"+str(self.partie[1]), self.gen_map(self.partie[1]))
                            

                        elif cmd == 2:
                            self.perso.reset()
                            self.partie = ["Gen", 0]
                            self.perso.map = 0
                            cmd = jeu(self, open_map("map/custom/" + ask(self, "Load Level] Level's name :")), self.perso)
                    elif cmd == 2:
                        cmd = self.multiplayer()
                    elif cmd == 3:
                        cmd =  menu(self, "Are you sure ?", ["Yes, delete "+self.perso.nom+" definitely !", "No, I want to keep "+self.perso.nom], self.perso)
                        if cmd == 1:
                            os.remove("data/perso/"+self.perso.nom)
                    elif cmd == 4:
                        old_name = self.perso.nom
                        while cmd != 3:
                            cmd =  menu(self, "Edit Character", ["Rename", "Change colors", "Done"], self.perso)
                            if cmd == 1:
                                self.perso.nom = ask(self, "Enter a name")
                            elif cmd == 2:
                                while cmd != 6:
                                    cmd = menu(self, "Choose "+self.perso.nom+"'s colors", ["Shirt", "Pants", "Hair", "Skin", "Other", "Done"], self.perso)
                                    if cmd != 6:
                                        menu_color(self, cmd-1, self.perso)
                        os.remove("data/perso/"+old_name)
                        self.perso.save()
        const.runned = False
        pygame.quit()
Beispiel #49
0
def jeu(app, map, perso):

    input = Input()

    for i in map:
        if isinstance(i, Porte):
            if i.id == perso.id_porte:
                perso.move_el(-perso.x, -perso.y)
                perso.move_el(i.x, i.y)

    fond = Element()
    if app.partie[1] >= 0:
        fond.changer_image(pygame.image.load(const.path_fond1).convert())
    else:
        fond.changer_image(pygame.image.load(const.path_fond2).convert())

    pointeur = element.Element()
    pointeur.changer_image(pygame.image.load("img/pointeur.png").convert_alpha())

    # Noir
    shadow = []
    shadow = set_shadow(shadow, map, app.perso)
    dark = Element()
    dark.changer_image(pygame.Surface((50, 50)))
    dark_middle = Element()
    dark_middle.changer_image(pygame.Surface((50, 50)))
    dark_middle.image.set_alpha(75)

    mobs = []
    mobs = popmobs(shadow, map)

    particules = []

    # interface
    coeur = Element()
    coeur.changer_image(pygame.image.load("img/coeur.png").convert_alpha())
    coeur.y = 540
    coeur_vide = Element()
    coeur_vide.changer_image(pygame.image.load("img/coeur_vide.png").convert_alpha())
    coeur_vide.y = 540

    b_fond_barre_energie = Element()
    b_fond_barre_energie.changer_image(pygame.Surface((102, 12)))
    b_fond_barre_energie.image.fill(pygame.Color(0, 0, 0, 255))
    b_fond_barre_energie.move_el(372, 568)
    fond_barre_energie = Element()
    fond_barre_energie.changer_image(pygame.Surface((100, 10)))
    fond_barre_energie.image.fill(pygame.Color(255, 255, 255, 255))
    fond_barre_energie.move_el(373, 569)
    barre_energie = Element()
    barre_energie.changer_image(pygame.Surface((100, 10)))
    barre_energie.image.fill(pygame.Color(255, 180, 40, 255))
    barre_energie.move_el(373, 569)
    energie = Element()
    energie.changer_image(pygame.image.load("img/energie.png").convert_alpha())
    energie.move_el(383, 569)

    b_text_item = Element()
    b_text_item.changer_text(perso.inv.get_item().nom, app.font_petit)
    b_text_item.move_el(384, 569)
    w_text_item = Element()
    w_text_item.changer_text(perso.inv.get_item().nom, app.font_petit)
    w_text_item.move_el(380, 565)
    b_text_item2 = Element()
    b_text_item2.changer_text("x" + str(perso.inv.get_item().nbr), app.font_petit)
    b_text_item2.move_el(384, 584)
    w_text_item2 = Element()
    w_text_item2.changer_text("x" + str(perso.inv.get_item().nbr), app.font_petit)
    w_text_item2.move_el(380, 580)

    fps = 0
    info_b_txt = []
    info_b_txt = write(app, "V. " + str(const.version) + "\nFPS : " + str(fps) + "\nGame : " + app.partie[0], 4, 4)
    info_w_txt = []
    info_w_txt = write(
        app, "V. " + str(const.version) + "\nFPS : " + str(fps) + "\nGame : " + app.partie[0], 0, 0, (255, 255, 255)
    )

    commandes = "(Space) : Jump\n(Mouse Left) : Hit\n(TAB) : Sprint\n(Mouse Right) : Use/Put a bloc\n(Mouse scroll) : Scroll inventory\n(i) : Inventory \n(v) : Change View\n(ESC) : Break"
    b_commandes = []
    b_commandes = write(app, commandes, 24, 64)
    w_commandes = []
    w_commandes = write(app, commandes, 20, 60, (255, 255, 255))

    # >> Multi
    # Nom joueurs
    nom_player_b = Element()
    nom_player_w = Element()
    # last_reset = time()

    cmd = 1
    prev = time() + 1

    if app.partie[0] == "Multi":
        map = const.map

    while not input.quit:
        if app.partie[0] == "Multi":
            for i in const.msg:
                const.chatbox.add(i)
            const.msg = []
            const.input_udp = (
                "set_pos;"
                + str(perso.x)
                + ";"
                + str(perso.y)
                + ";"
                + str(perso.v_x + perso.tend_x)
                + ";"
                + str(perso.v_y)
                + ";"
                + str(int(perso.sens))
                + ";"
                + str(int(perso.hitting))
                + ";"
                + str(int(perso.fired))
                + ";"
                + str(int(perso.issprinting))
                + ";"
                + str(perso.bras[0])
                + ";"
                + str(perso.bras[1])
            )
            for event in const.events_map:
                buffer = event.split(";")
                const.events_map.remove(event)
                if len(buffer) > 1:
                    print buffer
                    if buffer[1] == "hit_block":
                        x = int(buffer[2])
                        y = int(buffer[3])
                        damage = float(buffer[4])
                        for i in map:
                            if i.x == x and i.y == y:
                                if i.hit(damage, False):
                                    map.remove(i)
                    if buffer[1] == "destroy_block":
                        x = int(buffer[2])
                        y = int(buffer[3])
                        for i in map:
                            if i.x == x and i.y == y:
                                map.remove(i)
                    if buffer[1] == "set_block":
                        x = int(buffer[2])
                        y = int(buffer[3])
                        for i in map:
                            if i.x == x and i.y == y:
                                map.remove(i)
                        map.append(char2bloc(buffer[4]))
                    if buffer[1] == "lock_chest":
                        x = int(buffer[2])
                        y = int(buffer[3])
                        for i in map:
                            if i.x == x and i.y == y:
                                if isinstance(i, Coffre):
                                    i.lock = bool(int(buffer[4]))
                    elif buffer[1] == "add_block":
                        map.append(char2bloc(buffer[2]))

        # controle fps
        fps = int(1 / (time() - prev))
        while fps > const.fps:
            fps = int(1 / (time() - prev))

        info_b_txt = []
        info_b_txt = write(
            app,
            "V. "
            + str(const.version)
            + "\nFPS : "
            + str(fps)
            + "\nGame : "
            + app.partie[0]
            + "\nPlayer : "
            + perso.nom,
            4,
            4,
        )
        info_w_txt = []
        info_w_txt = write(
            app,
            "V. "
            + str(const.version)
            + "\nFPS : "
            + str(fps)
            + "\nGame : "
            + app.partie[0]
            + "\nPlayer : "
            + perso.nom,
            0,
            0,
            (255, 255, 255),
        )
        prev = time()

        barre_energie.image = pygame.transform.scale(barre_energie.image, (int(perso.energie), 10))
        if perso.inv.get_item().nbr > 1:
            b_text_item2.changer_text("x" + str(perso.inv.get_item().nbr), app.font_petit)
            w_text_item2.changer_text("x" + str(perso.inv.get_item().nbr), app.font_petit, (255, 255, 255))
        else:
            b_text_item2.changer_text("", app.font_petit)
            w_text_item2.changer_text("", app.font_petit, (255, 255, 255))

        # Shadow
        shadow = []
        shadow = set_shadow(shadow, map, app.perso)

        # Physique Liquide
        for i in map:
            if isinstance(i, Liquid):
                i.chuter(map)
                # i.put_nbr(app.font)
                if i.unit < 0.1:
                    map.remove(i)
        # Reset Blocs
        # if time()-last_reset > 10:
        #    last_reset = time()
        #    for i in copy.copy(map):
        #        if isinstance(i, Liquid):
        #            i.fixe = False

        # Hit perso
        for i in mobs:
            i.collided_perso(0, 0, perso)

        # Traitement events
        input.update_event(app)

        pointeur.move_el(-pointeur.x + input.mouse[0], -pointeur.y + input.mouse[1])
        if const.chatbox.writing:
            const.chatbox.input = input.write(const.chatbox.input, True)

        # Sprint
        """
        if  input.key[K_LSHIFT]:
            if time() > perso.sprint_lock:
                perso.issprinting = True
        else:
            perso.issprinting = False 
            """
        if input.key[K_SPACE] and input.key[K_a] and perso.issprinting and perso.vie > 0 and not const.chatbox.writing:
            perso.sauter(-5, -15, map)
            input.key[K_SPACE] = 0

        elif (
            input.key[K_SPACE] and input.key[K_d] and perso.issprinting and perso.vie > 0 and not const.chatbox.writing
        ):
            perso.sauter(5, -15, map)
            input.key[K_SPACE] = 0

        if input.key[K_SPACE] and perso.vie > 0 and not const.chatbox.writing:
            perso.sauter(0, -15, map)
            input.key[K_SPACE] = 0

        if input.get_mouse(app)[0] >= perso.x + 25:
            perso.sens = True
        else:
            perso.sens = False

        if input.mousebuttons[1] and time() - perso.last_hit > 0.3 and perso.vie > 0:
            last_hit = time()
            perso.hit()
            if app.coef == 1:
                coord = (int(input.mouse[0] / 50) * 50, int(input.mouse[1] / 50) * 50)
            else:
                coord = (
                    int((input.mouse[0] + app.pos_screen[0]) / 100) * 50,
                    int((input.mouse[1] + app.pos_screen[1]) / 100) * 50,
                )
            if math.sqrt((coord[0] - perso.x) ** 2 + (coord[1] - perso.y) ** 2) < 100:
                if not isinstance(perso.inv.get_item(), Item_Bloc):
                    perso.collided_type(-perso.x + coord[0], -perso.y + coord[1], map, Terre, particules)
                    perso.collided_type(-perso.x + coord[0], -perso.y + coord[1], map, Stone, particules)
                    perso.collided_type(-perso.x + coord[0], -perso.y + coord[1], map, Wood, particules)
                    perso.collided_type(-perso.x + coord[0], -perso.y + coord[1], map, Deco)
                    perso.collided_mob(mobs, particules)

        if input.mousebuttons[3] and perso.vie > 0:
            perso.hit()
            input.mousebuttons[3] = 0
            if app.coef == 1:
                coord = (int(input.mouse[0] / 50) * 50, int(input.mouse[1] / 50) * 50)
            else:
                coord = (
                    int((input.mouse[0] + app.pos_screen[0]) / 100) * 50,
                    int((input.mouse[1] + app.pos_screen[1]) / 100) * 50,
                )
            if math.sqrt((coord[0] - perso.x) ** 2 + (coord[1] - perso.y) ** 2) < 100:
                if isinstance(perso.inv.get_item(), Item_Bloc):

                    bloc = perso.inv.get_item().type(perso.inv.get_item().bloc.picture)
                    bloc.move_el(coord[0], coord[1])
                    if not perso.collided_bloc(0, 0, bloc):
                        collided = False
                        for i in map:
                            if i.x == bloc.x and i.y == bloc.y:
                                collided = True

                        if not collided:
                            map.append(bloc)
                            const.input.append("add_block;" + bloc2char(bloc))
                            perso.inv.delete()
                else:
                    perso.collided_utils(-perso.x + coord[0], -perso.y + coord[1], map, app, input)

        if not input.mousebuttons[1] and not input.mousebuttons[3]:
            perso.hitting = False
        if input.mousebuttons[4]:
            perso.inv.changer_select(-1)
            input.mousebuttons[4] = 0
        if input.mousebuttons[5]:
            perso.inv.changer_select(1)
            input.mousebuttons[5] = 0
        if input.key[K_i] and not const.chatbox.writing:
            atelier(app, perso, "Inventory")
            const.input.append("set_inv;" + perso.inv.save())
            input.key[K_i] = 0
        # Zoom
        if input.key[K_v] and not const.chatbox.writing:
            app.coef += 1
            if app.coef > 2:
                app.coef = 1
            input.key[K_v] = 0
        if perso.vie > 0 and not const.chatbox.writing:
            if input.key[K_w]:
                perso.monter_echelle(map)
            if input.key[K_LSHIFT] and time() > perso.sprint_lock:
                if input.key[K_a]:
                    perso.issprinting = True
                    perso.move(-10, 0, map)
                    perso.tend_x = -10
                    perso.anim(True)
                    if not perso.isingrav:
                        for it in range(random.randint(1, 5)):
                            new_particule = particule.Particule(6)
                            new_particule.move_el(perso.x + 40, perso.y + 50)
                            particules.append(new_particule)
                elif input.key[K_d]:
                    perso.issprinting = True
                    perso.move(10, 0, map)
                    perso.tend_x = 10
                    perso.anim(True)
                    if not perso.isingrav:
                        for it in range(random.randint(1, 5)):
                            new_particule = particule.Particule(7)
                            new_particule.move_el(perso.x + 10, perso.y + 50)
                            particules.append(new_particule)
                else:
                    perso.issprinting = False
            else:
                perso.issprinting = False
                if input.key[K_a]:
                    perso.move(-5, 0, map)
                    perso.tend_x = -5
                    perso.anim(True)
                    if not perso.isingrav:
                        if random.randint(1, 5) == 1:
                            new_particule = particule.Particule(8)
                            new_particule.move_el(perso.x + 40, perso.y + 50)
                            particules.append(new_particule)
                if input.key[K_d]:
                    perso.move(5, 0, map)
                    perso.tend_x = 5
                    perso.anim(True)
                    if not perso.isingrav:
                        if random.randint(1, 5) == 1:
                            new_particule = particule.Particule(9)
                            new_particule.move_el(perso.x + 10, perso.y + 50)
                            particules.append(new_particule)
        if not input.key[K_a] and not input.key[K_d]:
            perso.anim(False)
            perso.tend_x = 0
        if input.key[K_RETURN]:
            input.key[K_RETURN] = 0
            if perso.vie <= 0:
                perso.vie = perso.vie_max
                perso.fired = False
                for i in map:
                    if isinstance(i, Porte):
                        if i.id == perso.id_porte:
                            perso.move_el(-perso.x, -perso.y)
                            perso.move_el(i.x, i.y)
                mobs = popmobs(shadow, map)
            elif not const.chatbox.writing and app.partie[0] == "Multi":
                const.chatbox.writing = True
            elif const.chatbox.writing and app.partie[0] == "Multi":
                const.chatbox.writing = False
                const.chatbox.send()
        if input.key[K_ESCAPE]:
            input.key[K_ESCAPE] = 0
            if app.partie[0] != "Gen" and app.partie[0] != "Multi":
                cmd = menu(app, "Break", ["Resume", "Save game", "Quit"])
            else:
                cmd = menu(app, "Break", ["Resume", "Quit"])
            if cmd == 2:
                app.save_partie()
                save_map("save/" + app.partie[0] + "/map" + str(app.partie[1]), map)
            if cmd == 0:
                return 5

        perso.tomber(map)

        # Affichage
        app.blit(fond)

        for i in map:
            if isinstance(i, BlocMouvant):
                i.move()
                app.blit(i)
            elif isinstance(i, BlocDisp):
                i.disp()
                if i.etat:
                    app.blit(i)
            else:
                i.anim()
                app.blit(i)

        for i in mobs:
            i.update(map, perso)
            creat = True
            for coord_dark in shadow:
                if int(i.x / 50) == int(coord_dark[0] / 50) and int(i.y / 50) == int(coord_dark[1] / 50):
                    if coord_dark[2]:
                        creat = False
            if creat:
                i.update(map, perso)
                app.blit(i)
        for i in particules:
            i.update()
            app.blit(i)
            if time() - i.time_creat > 0.5:
                particules.remove(i)

        if app.partie[0] == "Multi":
            for i in const.persos:
                if i.map == perso.map:
                    i.tendance(map)
                    if i.hitting:
                        i.hit()

                    app.blit(i)

        app.blit(perso)

        for coord_dark in shadow:
            if coord_dark[2]:
                dark_middle.move_el(-dark_middle.x + coord_dark[0], -dark_middle.y + coord_dark[1])
                app.blit(dark_middle)
            else:
                dark.move_el(-dark.x + coord_dark[0], -dark.y + coord_dark[1])
                app.blit(dark)

        if app.coef > 1:
            app.scale(app.coef)

        if app.partie[0] == "Multi":
            for i in const.persos:
                if i.map == perso.map:
                    nom_player_b.changer_text(i.nom, app.font_petit, (0, 0, 0))
                    nom_player_w.changer_text(i.nom, app.font_petit, (255, 255, 255))
                    if app.coef == 1:
                        nom_player_b.move_el(-nom_player_b.x + i.x, -nom_player_b.y + i.y - 8)
                        nom_player_w.move_el(-nom_player_w.x + i.x - 2, -nom_player_w.y + i.y - 10)
                    else:
                        nom_player_b.move_el(
                            -nom_player_b.x + i.x * 2 - app.pos_screen[0],
                            -nom_player_b.y + (i.y - 8) * 2 - app.pos_screen[1],
                        )
                        nom_player_w.move_el(
                            -nom_player_w.x + (i.x - 2) * 2 - app.pos_screen[0],
                            -nom_player_w.y + (i.y - 10) * 2 - app.pos_screen[1],
                        )

                    app.blit(nom_player_b)
                    app.blit(nom_player_w)

        for i in range(perso.vie_max):
            if i < perso.vie:
                coeur.x = 370 + i * 15
                app.blit(coeur)
            else:
                coeur_vide.x = 370 + i * 15
                app.blit(coeur_vide)

        app.blit(perso.inv.get_element())
        app.blit(b_fond_barre_energie)
        app.blit(fond_barre_energie)
        app.blit(barre_energie)
        app.blit(energie)
        # app.blit(b_text_item)
        app.blit(b_text_item2)
        # app.blit(w_text_item)
        app.blit(w_text_item2)
        for i in info_b_txt:
            app.blit(i)
        for i in info_w_txt:
            app.blit(i)

        if input.key[K_TAB]:
            for i in b_commandes:
                app.blit(i)
            for i in w_commandes:
                app.blit(i)

        for i in map:
            if isinstance(i, Sign):
                if perso.collided_bloc(0, 0, i):
                    b_txt = []
                    b_txt = write(app, "Sign :\n\n     " + i.txt, 24, 204)
                    w_txt = []
                    w_txt = write(app, "Sign : \n\n     " + i.txt, 20, 200, (255, 255, 255))
                    for i in b_txt:
                        app.blit(i)
                    for i in w_txt:
                        app.blit(i)

        if app.partie[0] == "Multi":
            const.chatbox.blit_on(app)

        if perso.vie <= 0:
            b_txt = []
            b_txt = write(app, "Hard luck ! You are dead...\n\n      Press [RETURN] to respawn", 204, 204)
            w_txt = []
            w_txt = write(
                app, "Hard luck ! You are dead...\n\n      Press [RETURN] to respawn", 200, 200, (255, 255, 255)
            )
            for i in b_txt:
                app.blit(i)
            for i in w_txt:
                app.blit(i)

        app.blit(pointeur)

        app.flip()

        if perso.map != app.partie[1]:
            if app.partie[0] != "Gen" and app.partie[0] != "Multi":
                app.save_partie()
                save_map("save/" + app.partie[0] + "/map" + str(app.partie[1]), map)
            return 1
        if app.partie[1] == 19:
            if mobs[0].vie <= 0:
                cine(app, 2)
                return 5

    return 0