# You can place the script of your game in this file.

init:
    # Declare images below this line, using the image statement.
    # eg. image eileen happy = "eileen_happy.png"

    # Declare characters used by this game.
    $ e = Character('Eileen', color="#c8ffc8")
    $ nvle = Character(u"Эльза         ", color="#c8ffc8", kind=nvl)
    $ nvlk = Character(u"Каин           ", color="#c8ffc8", kind=nvl)
    $ nvlcrow = Character(u"Вороны      ", color="#c8ffc8", kind=nvl)
    $ nvlvoice = Character(u"Голос        ", color="#c8ffc8", kind=nvl)
    $ nvlpedergast = Character(u"Педергаст    ", color="#c8ffc8", kind=nvl)
    $ nvlhead = Character(u"Голова       ", color="#c8ffc8", kind=nvl)
    $ nvlesenia = Character(u"Есения       ", color="#c8ffc8", kind=nvl)
    $ nvlfather = Character(u"Отец         ", color="#c8ffc8", kind=nvl)
    $ nvlm = Character(u"Матильда     ", color="#c8ffc8", kind=nvl)
    $ nvldoctor = Character(u"Доктор       ", color="#c8ffc8", kind=nvl)
    $ nvlme = Character(u"Я            ", color="#c8ffc8", kind=nvl)
    $ n = Character("", color="#c8ffc8", kind=nvl)
    $ link = Character("", color="#c8ffc8", window_yminimum=600, window_left_padding=20,window_right_padding=20,window_top_padding=120)
    image bg sunset = "backgrounds/sunset.jpg"
    image bg sunflowers = "backgrounds/sunflowers.jpg"
    image bg door = "backgrounds/wall1.jpg"
    image bg podval = "backgrounds/wall_0.jpg"
    image pedergast = "characters/pedergast2.png"
    image esenia = "characters/esenia3.png"
    $ shoots =0
    $ hits = 0
    $ throws = 0
    $ showgamemenu = False

    python:

        # This function will run a countdown of the given length. It will
        # be white until 5 seconds are left, and then red until 0 seconds are
        # left, and then will blink 0.0 when time is up. 
        def countdown(st, at, length=0.0):

            remaining = length - st

            if remaining > 25.0:
                return Text("%.1f" % remaining, color="#fff", size=72), .1
            elif remaining > 20.0:
                return Text("%.1f" % remaining, color="#f00", size=72), .1
            elif remaining > 15.0:
                return Text("%.1f" % remaining, color="#fff", size=72), .1
            elif remaining > 10.0:
                return Text("%.1f" % remaining, color="#f00", size=72), .1
            elif remaining > 5.0:
                return Text("%.1f" % remaining, color="#fff", size=72), .1
            elif remaining > 0.0:
                return Text("%.1f" % remaining, color="#f00", size=72), .1
            else:
                return anim.Blink(Text("0.0", color="#f00", size=72)), None

    # Show a countdown for 10 seconds.
    image countdown = DynamicDisplayable(countdown, length=10.0)
    image countdown2 = DynamicDisplayable(countdown, length=20.0)
    image countdown3 = DynamicDisplayable(countdown, length=30.0)
    image countdown5 = DynamicDisplayable(countdown, length=5.0)


label die:
    nvl clear
    n "Игра окончена."
    jump finish

label splashscreen:
    $ renpy.pause(0)
    scene black
    show text u"Под лохматой елью,\nВ темном подземелье..."    with fade    
    $ renpy.pause(1.5)
    hide text    with fade
    return
    
# The game starts here.
label start:
    $ showgamemenu = True
    call chapter1
    call chapter2
    scene black
    "Продолжение следует..."

    
label finish:
    "..."
# This file adds a number of buttons to the lower-right hand corner of
# the screen. Three of these buttons jump to the game menu, which
# giving quick access to Load, Save, and Prefs. The fourth button
# toggles skipping, to make that more convenient.

init python:
    
    # Give us some space on the right side of the screen.
    style.window.right_padding = 100

    def toggle_skipping():
        config.skipping = not config.skipping

    show_button_game_menu = True

    def button_game_menu():

        if show_button_game_menu and showgamemenu:

            # to save typing
            ccinc = renpy.curried_call_in_new_context

            ui.vbox(xpos=0.99, ypos=0.98, xanchor='right', yanchor='bottom')
            ui.textbutton(u"Пропустить", clicked=toggle_skipping, xminimum=200)
            ui.textbutton(u"Сохранить", clicked=ccinc("_game_menu_save"), xminimum=200)
            #ui.textbutton(u"Загрузить", clicked=ccinc("_game_menu_load"), xminimum=200)
            ui.textbutton(u"Опции", clicked=ccinc("_game_menu_preferences"), xminimum=200)
            ui.close()


    config.overlay_functions.append(button_game_menu)


