Как сделать игру кликер? (How to make a clicker game?)

Материал из Ren'Py Wiki
Перейти к навигации Перейти к поиску

Первый пример:

default points=10
default plus=2
default max_point=30
default clicked = True

# Экран кликера
screen clicker:
    modal True
    timer .5 repeat True action [If(points <= 0, true=Jump("lost"), false=SetVariable("points", points - plus))]
    button:
        text "[points] / [max_point]" size 40
        background "#000"
        xpos .5
        ypos .5
        xysize(300, 300)
        action [SetVariable("clicked", True), If(points >= max_point, true=Jump("win"), false=SetVariable("points", points + plus))]
    vbar value StaticValue(points, max_point)

# Игра начинается здесь
label start:
    centered "Приготовьтесь!{w=1}{nw}"
    call screen clicker

label win:
    $ renpy.pause(2, hard=True)
    centered "Вы победили!"
    return

label lost:
    centered "Вы проиграли."
    return


Во втором примере добавим эмоции и звук:

default points=10
default plus=2
default max_point=30
default clicked = True

init:
    image happy = "happy.png"
    image neitr = "neitral.png"
    image sadd = "sad.png"

# Экран кликера
screen clicker:
    modal True
    timer .5 repeat True action [If(points <= 0, true=Jump("lost"), false=SetVariable("points", points - plus))]
    button:
        text "[points] / [max_point]" size 40
        background "#000"
        xpos .5
        ypos .5
        xysize(300, 300)
        action [SetVariable("clicked", True), If(points >= max_point, true=Jump("win"), false=SetVariable("points", points + plus)), Play("sound", "click.ogg")] # Добавьте файл click.ogg в папку 'game'.
    if points>=20:
        add "happy" xalign .3 yalign 1.0
    elif points<10:
        add "sadd" xalign .3 yalign 1.0
    else:
        add "neitr" xalign .3 yalign 1.0

# Игра начинается здесь
label start:
    centered "Приготовьтесь!{w=1}{nw}"
    call screen clicker

label win:
    $ renpy.pause(2, hard=True)
    centered "Вы победили!"
    return

label lost:
    centered "Вы проиграли."
    return


Третий пример:

default points=10
default plus=2
default max_point=30
default clicked = True

# Экран кликера
screen clicker:
    modal True
    timer .25 repeat True action [If(points <= 0, true=Jump("lost"), false=SetVariable("points", points - plus))]
    button:
        xpos .3
        ypos .1
        xysize(300, 500)
        action [SetVariable("clicked", True), If(points >= max_point, true=Jump("win"), false=SetVariable("points", points + plus))]
    bar value StaticValue(points, max_point):
        xalign 0.45 yalign 0.0
        xmaximum 400 
        ymaximum 15

# Игра начинается здесь        
label start:
    play movie "clickergame.ogv" loop
    show movie with fade
    centered "Нажмите в центре!{w=1}{nw}"
    call screen clicker

label win:
    $ renpy.pause(2, hard=True)
    centered "Вы победили!"
    return

label lost:
    centered "Вы проиграли."
    return

Источник[править | править код]

Статья "How to make a clicker game?" на английском языке.


На главную страницу Книга рецептов Энциклопедии Ren'Py Форумы Lemma Soft Вернуться к началу статьи