def interact(game):
    # interaction entre l'utilisateur et le menu
    menu = Game.getMenu(game)
    win = Game.getWin(game)
    # deplacement du curseur
    menu['selectedItem'] = -1
    key = win.getch()
    if key == ord('z'):
        if menu['cursor'] != 0:
            menu['cursor'] -= 1
    if key == ord('s'):
        if menu['cursor'] != len(menu['items']) - 1:
            menu['cursor'] += 1
    if key == ord('e'):
        menu['selectedItem'] = menu['cursor']
    # action a effectuer en fonction de l'item selectionne
    if menu['selectedItem'] == 0:
        game = Game.setName(Game.askName(game), game)
    if menu['selectedItem'] == 1:
        game = Game.setDifficulty(Game.askDifficulty(game), game)
    if menu['selectedItem'] == 2:
        newLevel = Level.create(Level.askLevelNumber(game), 'levels.txt')
        logging.info("nouveau niveau : " + str(newLevel))
        game = Game.setLevel(newLevel, game)
    if menu['selectedItem'] == 3:
        HighScores.show(HighScores.get(), win)
    if menu['selectedItem'] == 4:
        Game.setState('game', game)
    if menu['selectedItem'] == 5:
        Game.setState('quitProgram', game)
    return
def init():
    # on initialise la fenetre curses
    curses.initscr()
    win = curses.newwin(30, 80, 0, 0)
    curses.noecho()
    curses.curs_set(0)
    win.nodelay(1)

    logging.basicConfig(filename='snake.log', level=logging.INFO)
    # creation du niveau
    level = Level.create(1, 'levels.txt')
    # creation du snake
    snake = Snake.create(35, 15, 1, 2)

    # creation du food
    food = None

    # creation du menu
    menu = Menu.create(
        'Change name',
        'Change difficulty',
        'Select level',
        'Show HighScores',
        'Play',
        'Quit game'
    )

    # definition de l'etat du programme
    state = 'menu'

    # definition du nom du joueur
    name = 'player1'

    # definition de la difficulte
    difficulty = 2

    score = -1

    HighScoreTable = HighScores.get()
    # creation de la variable de type game
    game = Game.create(
        menu,
        level,
        snake,
        food,
        win,
        state,
        name,
        difficulty,
        score,
        HighScoreTable
        )

    return game