def drawLives():
    posx = (-stage.width / 2) + 3
    for x in xrange(1, game.lives + 1):
        posx += 1
        drawTile(posx, (-stage.height / 2) - 1, theme.get_tile('lives'), theme.get_color('lives'))
        posx += 1
        drawTile(posx, (-stage.height / 2) - 1, theme.get_tile('border-h'), theme.get_color('border'))
示例#2
0
def drawInitGame():
    drawTile(-5, -2, _("  Welcome to SNAKE "), theme.get_color('border'))
    drawTile(-4, 2, _(" Press [ENTER] "), theme.get_color('border'))
    left = u"\u2190"
    up = u"\u2191"
    down = u"\u2193"
    right = u"\u2192"
    drawTile(-5, 4, _(" Use [{0}{1}{2}{3}] to move ").format(left, up, down, right), theme.get_color('border'))
示例#3
0
def drawInitGame():
    drawTile(-5, -2, "  Welcome to SNAKE ", theme.get_color('border'))
    drawTile(-4, 2, " Press [ENTER] ", theme.get_color('border'))
    left = u"\u2190"
    up = u"\u2191"
    down = u"\u2193"
    right = u"\u2192"
    drawTile(-5, 4, " Use [" + left + up + down + right + "] to move ", theme.get_color('border'))
示例#4
0
def drawLives():
    posx = (-stage.width / 2) + 3
    for x in xrange(1, game.lives + 1):
        posx += 1
        drawTile(posx, (-stage.height / 2) - 1, theme.get_tile('lives'),
                 theme.get_color('lives'))
        posx += 1
        drawTile(posx, (-stage.height / 2) - 1, theme.get_tile('border-h'),
                 theme.get_color('border'))
def drawBorders():
    for y in range(stage.boundaries['top'], stage.boundaries['bottom']):
        drawTile(stage.boundaries['left'] - 1, y, theme.get_tile('border-v'), theme.get_color('border'))
        drawTile(stage.boundaries['right'], y, theme.get_tile('border-v'), theme.get_color('border'))

    for x in range(stage.boundaries['left'], stage.boundaries['right']):
        drawTile(x, stage.boundaries['top'] - 1, theme.get_tile('border-h'), theme.get_color('border'))
        drawTile(x, stage.boundaries['bottom'], theme.get_tile('border-h'), theme.get_color('border'))
            
    drawTile(stage.boundaries['left'] - 1, stage.boundaries['top'] - 1, theme.get_tile('border-c'), theme.get_color('border'))
    drawTile(stage.boundaries['left'] - 1, stage.boundaries['bottom'], theme.get_tile('border-c'), theme.get_color('border'))
    drawTile(stage.boundaries['right'], stage.boundaries['top'] - 1, theme.get_tile('border-c'), theme.get_color('border'))
    drawTile(stage.boundaries['right'], stage.boundaries['bottom'], theme.get_tile('border-c'), theme.get_color('border'))
def drawSnake():
    for part in game.snake:
        drawTile(
            part[0],
            part[1],
            theme.get_tile('snake-body'),
            theme.get_color('snake')
            )
    # Clean last tile
    drawTile(
        game.lastPos[0],
        game.lastPos[1],
        theme.get_tile('bg'),
        theme.get_color('bg')
        )
示例#7
0
def drawHeader():
    header = []
    header.append(
        ".-------------------------------------------------------------.")
    header.append(
        "|  .---._____     ______     ______     ______     _____      |")
    header.append(
        "| (  8  ____ \___/ ____ \___/ ____ \___/ ____ \___/ ____`=-   |")
    header.append(
        "|  '---'    \_____/    \_____/    \_____/    \_____/          |")
    header.append(
        "|   ____              _          _____    _ _ _               |")
    header.append(
        "|  / ___| _ __   __ _| | _____  | ____|__| (_) |_ ___  _ __   |")
    header.append(
        "|  \___ \| '_ \ / _` | |/ / _ \ |  _| / _` | | __/ _ \| '__|  |")
    header.append(
        "|   ___) | | | | (_| |   <  __/ | |__| (_| | | || (_) | |     |")
    header.append(
        "|  |____/|_| |_|\__,_|_|\_\___| |_____\__,_|_|\__\___/|_|     |")
    header.append(
        "|                                                             |")
    header.append(
        "'-------------------------------------------------------------'")
    x = (stage.width / 2) - 25
    y = (-stage.height / 2) - 15
    color = theme.get_color('menu')
    for e in header:
        drawTile(x, y, e, color)
        y += 1
示例#8
0
def drawText():
    color = theme.get_color('border')
    score_text = _("score:")
    drawTile((stage.width / 2) - (len(score_text) / 2) - 2,
             (-stage.height / 2) - 1, score_text, color)
    drawTile((-stage.width / 2), (-stage.height / 2) - 1, _("lives:"), color)
    drawTile(-5, (stage.height / 2), _(" Press Q to quit "), color)
def drawScore():
    score_formatted = str(game.score).zfill(2)
    drawTile(
        (stage.width / 2) - 1,
        (-stage.height / 2) - 1,
        score_formatted,
        theme.get_color('border')
        )
示例#10
0
def drawSnake():
    for part in game.snake:
        drawTile(
            part[0],
            part[1],
            theme.get_tile('snake-body'),
            theme.get_color('snake')
        )
示例#11
0
def drawApples():
    for apple in game.apples:
        drawTile(
            apple[0],
            apple[1],
            theme.get_tile('apple'),
            theme.get_color('apple')
            )
示例#12
0
def drawSnake():
    for part in game.snake:
        drawTile(
            part[0],
            part[1],
            theme.get_tile('snake-body'),
            theme.get_color('snake')
        )
示例#13
0
def drawGameOver():
    speed = gameloop.speed
    size = stage.passSize
    lives = game.lives
    sizeStr = ''
    speedStr = ''
    livesStr = str(lives)
    # set speed string
    if(speed == .2):
        speedStr = 'Slow'
    elif(speed == .12):
        speedStr = 'Medium'
    elif(speed == .07):
        speedStr = 'Fast'
    # set size string
    if(size == 's'):
        sizeStr = 'Small'
    elif(size == 'm'):
        sizeStr = 'Medium'
    elif(size == 'l'):
        sizeStr = 'Large'
    drawTile(-4, -10, "  GAME OVER  ", theme.get_color('border'))
    drawTile(-3, -8, "Score:" + str(game.score), theme.get_color('border'))
    drawTile(-3, -6, "Speed:" + speedStr, theme.get_color('border'))
    drawTile(-3, -4, "Size:" + sizeStr, theme.get_color('border'))
    drawTile(-3, -2, "Lives:" + livesStr, theme.get_color('border'))

    if parser.args.tutorial:
        drawTile(-6, 2, " Press [ENTER] to exit ", theme.get_color('border'))
    else:
        drawTile(-7, 2, " Press [ENTER] to continue ", theme.get_color('border'))
示例#14
0
def drawTile(x, y, tile='', color=None):
    color = color or theme.get_color('default')

    x = x * 2 + stage.padding[3] * 2 + stage.width / 2
    y += stage.padding[0] + stage.height / 2

    screen.addstr(y, x, tile, color)
    if (len(tile) < 2):
        screen.addstr(y, x + 1, tile, color)
示例#15
0
def drawTile(x, y, tile='', color=None):
    color = color or theme.get_color('default')

    x = x * 2 + stage.padding[3] * 2 + stage.width / 2
    y += stage.padding[0] + stage.height / 2

    try:
        screen.addstr(y, x, tile, color)
        if (len(tile) < 2):
            screen.addstr(y, x + 1, tile, color)
    except:
        # This is not the built-in exit, rather the one declared later on
        exit()
示例#16
0
def drawHeader():
    header = []
    header.append(".-------------------------------------------------------------.")
    header.append("|  .---._____     ______     ______     ______     _____      |")
    header.append("| (  8  ____ \___/ ____ \___/ ____ \___/ ____ \___/ ____`=-   |")
    header.append("|  '---'    \_____/    \_____/    \_____/    \_____/          |")
    header.append("|   ____              _          _____    _ _ _               |")
    header.append("|  / ___| _ __   __ _| | _____  | ____|__| (_) |_ ___  _ __   |")
    header.append("|  \___ \| '_ \ / _` | |/ / _ \ |  _| / _` | | __/ _ \| '__|  |")
    header.append("|   ___) | | | | (_| |   <  __/ | |__| (_| | | || (_) | |     |")
    header.append("|  |____/|_| |_|\__,_|_|\_\___| |_____\__,_|_|\__\___/|_|     |")
    header.append("|                                                             |")
    header.append("'-------------------------------------------------------------'")
    x = (stage.width / 2) - 25
    y = (-stage.height / 2) - 15
    color = theme.get_color('menu')
    for e in header:
        drawTile(x, y, e, color)
        y += 1
示例#17
0
def drawBorders():
    tile_v = theme.get_tile('border-v')
    tile_h = theme.get_tile('border-h')
    tile_c = theme.get_tile('border-c')
    color = theme.get_color('border')

    x_left = stage.boundaries['left']
    x_right = stage.boundaries['right']

    y_top = stage.boundaries['top']
    y_bottom = stage.boundaries['bottom']

    for y in range(y_top, y_bottom):
        drawTile(x_left - 1, y, tile_v, color)
        drawTile(x_right, y, tile_v, color)

    for x in range(x_left, x_right):
        drawTile(x, y_top - 1, tile_h, color)
        drawTile(x, y_bottom, tile_h, color)

    drawTile(x_left - 1, y_top - 1, tile_c, color)
    drawTile(x_left - 1, y_bottom, tile_c, color)
    drawTile(x_right, y_top - 1, tile_c, color)
    drawTile(x_right, y_bottom, tile_c, color)
示例#18
0
def drawCurrentMenu():
    # Clean tiles
    for x in xrange(TitleXPos, -1 * TitleXPos):
        for y in xrange(menuYPos, 25):
            drawTile(x, y, '  ', theme.get_color('menu'))
    x = menuXPos
    idx = 0
    # Draw Menu
    # Title
    y = menuYPos - menuYInc
    auxX = TitleXPos
    for e in controls.get_menu_title():
        drawTile(TitleXPos, y, e, theme.get_color('menu'))
        if e != '' and e != '.Board' and e != '.Elements':
            drawTile(auxX, y - 1, "| ", theme.get_color('menu'))
            auxX += 1
        y += menuYInc
    y = menuYPos
    # Options
    for string in controls.currentMenu:
        # Color menu
        if controls.currentMenu == menus.colors:
            color = menus.colors[idx][0]
            if controls.currentIdx == idx:
                head = '> ['
            else:
                head = '  ['
            text = '    ] ' + _(string[0])
            drawTile(x, y, text, theme.get_color('menu'))
            drawTile(x, y, '    ', theme.get_color(color))
            drawTile(x, y, head, theme.get_color('menu'))
        # Symbol menu
        elif controls.symbolMode:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
                if len(controls.tile) > 0:
                    text += ' : ' + controls.tile[0]
                    if len(controls.tile) > 1:
                        text += ' ' + controls.tile[1]
                        text += '   >> ' + _('Press [ENTER]')
                    else:
                        text += ' _'
                else:
                    text += ' : _ _'
            else:
                text = '  ' + string[0]
            drawTile(x, y, text, theme.get_color('menu'))
        # Naming mode
        elif controls.nameMode:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
                if len(controls.tile) > 0:
                    text += ' : ' + controls.tile
                else:
                    text += ' : '
            else:
                text = '  ' + string[0]
            drawTile(x, y, text, theme.get_color('menu'))
        # Rest
        else:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
            else:
                text = '  ' + string[0]
            # Exception: show delete in red if theme is custom-theme
            if string[0] == _('Delete Theme') and controls.theme_name == os.path.splitext(theme.CUSTOM_THEME)[0]:
                colour = theme.get_color('Red')
            else:
                colour = theme.get_color('menu')
            drawTile(x, y, text, colour)
        y += menuYInc
        idx += 1
示例#19
0
def drawGame():
    for y in range(stage.boundaries['top'], stage.boundaries['bottom']):
        for x in range(stage.boundaries['left'], stage.boundaries['right']):
            drawTile(x, y, theme.get_tile('bg'), theme.get_color('bg'))
    drawBorders()
    drawText()
示例#20
0
def drawCurrentMenu():
    # Clean tiles
    for x in xrange(TitleXPos, -1 * TitleXPos):
        for y in xrange(menuYPos, 25):
            drawTile(x, y, '  ', theme.get_color('menu'))
    x = menuXPos
    idx = 0
    # Draw Menu
    # Title
    y = menuYPos - menuYInc
    auxX = TitleXPos
    for e in controls.get_menu_title():
        drawTile(TitleXPos, y, e, theme.get_color('menu'))
        if e != '' and e != '.Board' and e != '.Elements':
            drawTile(auxX, y - 1, "| ", theme.get_color('menu'))
            auxX += 1
        y += menuYInc
    y = menuYPos
    # Options
    for string in controls.currentMenu:
        # Color menu
        if controls.currentMenu == menus.colors:
            color = menus.colors[idx][0]
            if controls.currentIdx == idx:
                head = '> ['
            else:
                head = '  ['
            text = '    ] ' + _(string[0])
            drawTile(x, y, text, theme.get_color('menu'))
            drawTile(x, y, '    ', theme.get_color(color))
            drawTile(x, y, head, theme.get_color('menu'))
        # Symbol menu
        elif controls.symbolMode:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
                if len(controls.tile) > 0:
                    text += ' : ' + controls.tile[0]
                    if len(controls.tile) > 1:
                        text += ' ' + controls.tile[1]
                        text += '   >> ' + _('Press [ENTER]')
                    else:
                        text += ' _'
                else:
                    text += ' : _ _'
            else:
                text = '  ' + string[0]
            drawTile(x, y, text, theme.get_color('menu'))
        # Naming mode
        elif controls.nameMode:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
                if len(controls.tile) > 0:
                    text += ' : ' + controls.tile
                else:
                    text += ' : '
            else:
                text = '  ' + string[0]
            drawTile(x, y, text, theme.get_color('menu'))
        # Rest
        else:
            if controls.currentIdx == idx:
                text = '> ' + string[0]
            else:
                text = '  ' + string[0]
            # Exception: show delete in red if theme is custom-theme
            if string[0] == _('Delete Theme'
                              ) and controls.theme_name == os.path.splitext(
                                  theme.CUSTOM_THEME)[0]:
                colour = theme.get_color('Red')
            else:
                colour = theme.get_color('menu')
            drawTile(x, y, text, colour)
        y += menuYInc
        idx += 1
示例#21
0
def drawText():
    color = theme.get_color('border')
    score_text = _("score:")
    drawTile((stage.width / 2) - (len(score_text) / 2) - 2, (-stage.height / 2) - 1, score_text, color)
    drawTile((-stage.width / 2), (-stage.height / 2) - 1, _("lives:"), color)
    drawTile(-5, (stage.height / 2), _(" Press Q to quit "), color)
示例#22
0
def drawGameOver():
    drawTile(-4, -1, " GAME OVER ", theme.get_color('border'))
    drawTile(-7, 1, " Press ENTER to restart ", theme.get_color('border'))
示例#23
0
def drawText():
    color = theme.get_color('border')
    drawTile((stage.width / 2) - 4, (-stage.height / 2) - 1, "score:", color)
    drawTile((-stage.width / 2), (-stage.height / 2) - 1, "lives:", color)
    drawTile(-5, (stage.height / 2), " Press Q to quit ", color)